Condition Variable - Wait/Notify Race Condition
I'll present some code first since explaining is easier that way. Assume that mutexes are correctly used with the condition variables to keep it simple: // Thread 1 while(1) { conditionVariable.wait(); // Do some work } // Thread 2 while(1) { // Do some work conditionVariable.notify_one(); } // Thread 3 while(1) { // Do some work conditionVariable.notify_one(); } What I would like to achieve is that thread 1 is guaranteed to be waiting on the condition variable when thread 2 or Thread 3 notifies. As the code stands, there is a large gap between notify_one() and wait() in the form of some other