Chapter 11 Synchronization Primitives and Patterns
- 11.1 Shared-Memory Synchronization Patterns
- 11.2 Mutex
- 11.3 Atomic Operations
- 11.4 Condition Variable
- 11.5 Wait Group
- 11.6 Cache Pool
- 11.7 Concurrent-Safe Hash Map
- 11.8 Context
- 11.9 Memory Consistency Model
In modern programming languages, synchronization between multiple threads is usually achieved through traditional shared-memory mechanisms such as mutexes and semaphores. Go takes a different path from most languages in its choice of synchronization primitives: message-passing synchronization based on channels and select is the language’s true synchronization primitive in the proper sense. The concepts that are “traditionally” treated as primitives, such as atomics, mutexes, condition variables, and thread-local resources, are recast in Go as user-space synchronization patterns, giving the language its own distinctive character.