A Real Condition For A Condition Variable (Cont.) Lets analyze some possible scenarios. we'll name the signaling thread 'S' and the waiting thread 'W'. Scenario 1: Thread W locks the mutex, the queue is empty. Thread W blocks on the cond variable. The mutex is unlocked. Thread S locks the mutex. Thread S inserts an element to the queue. Thread S signals the cond var. Since it holds the mutex lock, thread W is still blocked in 'pthread_cond_wait'. Thread S unlocks the mutex. Thread W returns from 'pthread_cond_wait' with the mutex locked. The queue has 1 element. Thread W exits the 'while' loop and extracts the element from the queue. Thread W unlocks the mutex, and goes to handle the element.