Go · Class
sync.Mutex
sync.Mutex provides mutual exclusion: one goroutine can hold the lock at a time. Lock waits for ownership, TryLock attempts without waiting, and Unlock releases the lock.
Last updated
Syntax
type Mutex struct
func (m *Mutex) Lock()
func (m *Mutex) TryLock() bool
func (m *Mutex) Unlock()In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
LockTryLockUnlocksync.MutexchannelWaitGroup