Multithreading: Condition Variables
Synchronizing threads via notifications is a simple concept, but condition variables make this task really challenging - mostly because the condition variables have no state.
- If a condition variable gets a notification, it may be the wrong one spurious wakeup.
- If a condition variable gets its notification before it was ready, the notification will be lost lost wakeup.
Don’t use condition variables without a predicate
Using a condition variable without a predicate is a race condition.