Skip to content

Condition Variables

A condition variable lets threads sleep until shared state may satisfy a predicate.

flowchart LR J[Junior: wait in a loop] --> M[Middle: avoid lost wakeups] --> S[Senior: lifecycle safety] --> P[Professional: monitor internals]
flowchart LR Lock --> Check{Predicate true?} Check -->|no| Wait[Atomically unlock and wait] Wait --> Lock Check -->|yes| Work
Level Guide You are done when
Junior Start You can wait on a predicate in a loop.
Middle Apply You can signal without lost wakeups.
Senior Operate You can design shutdown-safe coordination.
Professional Design You can evaluate monitor implementations.

Practice rule: The predicate is the truth; notification only says to check again.

Mutex | Channels