Lesson 16 of 60
GoAtomic Operations & Mutexes
20 minutes
Course progress27%
Synchronization Primitives
This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.
sync.Mutex
var mu sync.Mutex
counter := 0
for i := 0; i < 100; i++ {
go {
mu.Lock()
counter++
mu.Unlock()
}()
}