parent
86b0df9895
commit
94cba6875d
@ -1,6 +1,6 @@
|
|||||||
// In the previous example we saw how to manage simple
|
// In the previous example we saw how to manage simple
|
||||||
// counter state using atomic operations. For more complex
|
// counter state using [atomic operations](atomic-counters).
|
||||||
// state we can use a _[mutex](http://en.wikipedia.org/wiki/Mutual_exclusion)_
|
// For more complex state we can use a _[mutex](http://en.wikipedia.org/wiki/Mutual_exclusion)_
|
||||||
// to safely access data across multiple goroutines.
|
// to safely access data across multiple goroutines.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
a42e6b574ab2c2bdd38df53d77b9a2f3f3e0b10c
|
3ce8467418aa740ea6c930afac3985a943c76311
|
||||||
-_LKNceBru
|
kZrod-Rkos
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// In the previous example we used explicit locking with
|
// In the previous example we used explicit locking with
|
||||||
// mutexes to synchronize access to shared state across
|
// [mutexes](mutexes) to synchronize access to shared state
|
||||||
// multiple goroutines. Another option is to use the
|
// across multiple goroutines. Another option is to use the
|
||||||
// built-in synchronization features of goroutines and
|
// built-in synchronization features of goroutines and
|
||||||
// channels to achieve the same result. This channel-based
|
// channels to achieve the same result. This channel-based
|
||||||
// approach aligns with Go's ideas of sharing memory by
|
// approach aligns with Go's ideas of sharing memory by
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
9b7362872b9984296fd919441c2b6928ae0d70c1
|
603a70a77ed18db9da4f8c7911a92b87fd21400c
|
||||||
qHTT2jOKkS
|
-WqmiTr6ek
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="docs">
|
<td class="docs">
|
||||||
<p>In the previous example we saw how to manage simple
|
<p>In the previous example we saw how to manage simple
|
||||||
counter state using atomic operations. For more complex
|
counter state using <a href="atomic-counters">atomic operations</a>.
|
||||||
state we can use a <em><a href="http://en.wikipedia.org/wiki/Mutual_exclusion">mutex</a></em>
|
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>
|
to safely access data across multiple goroutines.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
@ -42,7 +42,7 @@ to safely access data across multiple goroutines.</p>
|
|||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<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>
|
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="docs">
|
<td class="docs">
|
||||||
<p>In the previous example we used explicit locking with
|
<p>In the previous example we used explicit locking with
|
||||||
mutexes to synchronize access to shared state across
|
<a href="mutexes">mutexes</a> to synchronize access to shared state
|
||||||
multiple goroutines. Another option is to use the
|
across multiple goroutines. Another option is to use the
|
||||||
built-in synchronization features of goroutines and
|
built-in synchronization features of goroutines and
|
||||||
channels to achieve the same result. This channel-based
|
channels to achieve the same result. This channel-based
|
||||||
approach aligns with Go’s ideas of sharing memory by
|
approach aligns with Go’s ideas of sharing memory by
|
||||||
@ -46,7 +46,7 @@ by exactly 1 goroutine.</p>
|
|||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<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>
|
<div class="highlight"><pre><span class="kn">package</span> <span class="nx">main</span>
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user