Condition variables. Threading libraries often provide condition variables, which
are sort of like monitor condition variables. C++-11:
// Condition varibles use a mutex, which stands in for the
// mutual exclusion provided by a monitor.
mutex mux;
condition_variable available;
...
// To wait for the resource to be available
unique_lock<mutex> locker(mux); // Locks the mutex.
available.wait(locker);
// Unlocks the mutex, then the caller sleeps until awoken.
// Before being awoken, the mutex is locked again.
...
// To indicate that the resource is available, another thread does:
available.notify_one();
// or
available.notify_all();