@@ -26,8 +26,8 @@
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>In the previous example we saw how to manage simple
|
||||
counter state using atomic operations. For more complex
|
||||
state we can use a <em><a href="http://en.wikipedia.org/wiki/Mutual_exclusion">mutex</a></em>
|
||||
counter state using <a href="atomic-counters">atomic operations</a>.
|
||||
For more complex state we can use a <em><a href="http://en.wikipedia.org/wiki/Mutual_exclusion">mutex</a></em>
|
||||
to safely access data across multiple goroutines.</p>
|
||||
|
||||
</td>
|
||||
@@ -42,7 +42,7 @@ to safely access data across multiple goroutines.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/-_LKNceBru"><img title="Run code" src="play.png" class="run" /></a>
|
||||
<a href="http://play.golang.org/p/kZrod-Rkos"><img title="Run code" src="play.png" class="run" /></a>
|
||||
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
<tr>
|
||||
<td class="docs">
|
||||
<p>In the previous example we used explicit locking with
|
||||
mutexes to synchronize access to shared state across
|
||||
multiple goroutines. Another option is to use the
|
||||
<a href="mutexes">mutexes</a> to synchronize access to shared state
|
||||
across multiple goroutines. Another option is to use the
|
||||
built-in synchronization features of goroutines and
|
||||
channels to achieve the same result. This channel-based
|
||||
approach aligns with Go’s ideas of sharing memory by
|
||||
@@ -46,7 +46,7 @@ by exactly 1 goroutine.</p>
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="http://play.golang.org/p/qHTT2jOKkS"><img title="Run code" src="play.png" class="run" /></a>
|
||||
<a href="http://play.golang.org/p/-WqmiTr6ek"><img title="Run code" src="play.png" class="run" /></a>
|
||||
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre></div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user