Skip to main content
InterviewHubPRO
Section Overview
Q21

Question 21 of 50

Part 2: Concurrency, Channels & The GMP Scheduler (16 - 32)

42%
Golang & Concurrency (50 Qs)•Part 2: Concurrency, Channels & The GMP Scheduler (16 - 32)

Synchronization Primitives: `sync.Mutex`, `sync.RWMutex`, and `sync.WaitGroup`.

senior LevelGolang

In Simple Words:

  • sync.Mutex: Exclusive mutual exclusion lock (Lock() / Unlock()).
  • sync.RWMutex: Reader/Writer lock. Multiple readers can hold RLock() concurrently. A writer acquiring Lock() blocks all new readers and writers. Best for read-heavy caches.
  • sync.WaitGroup: Coordinates concurrent tasks: Add(delta), Done(), and Wait(). Always pass WaitGroups by pointer!