Go Package sync: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 14: Line 14:
=<tt>Mutex</tt>=
=<tt>Mutex</tt>=
{{Internal|Go Mutex#Overview|<tt>Mutex</tt>}}
{{Internal|Go Mutex#Overview|<tt>Mutex</tt>}}
=TO DISTRIBUTE=
<FONT COLOR=darkkhaki>
==Mutex==
* <tt>[https://golang.org/pkg/sync/#Mutex sync.Mutex]</tt>
A Mutex is a mutual exclusion lock. Only one goroutine can enter the critical section at a time. Not until the call to the <tt>Unlock()</tt> function issued can another goroutine enter the critical section.
Usage pattern (the curly braces are not necessary):
<pre>
var mutex sync.Mutex
...
mutex.Lock() {
    // do something in a mutual exclusion mode
}
mutex.Unlock()
</pre>
</FONT>

Revision as of 21:53, 1 September 2023

External

Internal

Overview

The sync package provides synchronization primitives to use when synchronization between goroutines is necessary.

WaitGroup

WaitGroup

Mutex

Mutex