concurrency
Wait on a condition in a loop
Anonymous
A condition-variable wait should usually sit inside a loop that checks the shared condition again. A thread can wake without the condition being true, or another thread can change it before the awakened thread runs. The loop protects the invariant; the lock protects the shared state.
0