Standard library / sync
sync.Mutex.Lock()
Acquire exclusive ownership of the lock, blocking if needed. Mutex is not reentrant. Expected stdout: 'locked\n'.
Formal Syntax & Structure
go syntaxgo
func (m *Mutex) Lock()Working Example
Example Snippetgo
package main
import ( "fmt" "sync")
func main() { var m sync.Mutex; m.Lock(); fmt.Println("locked"); m.Unlock() }