We learned how to synchronize simultaneous access to the same variable from two or more threads. The particular order in which threads accessed the variable was not important; we only prevented simultaneous reads and writes to the variable.
A thread waiting for another thread to start processing data is a common scenario. In this case, the second thread should be notified by the first thread when the data is available. It can be done using condition variables, supported by C++, starting from the C++11 standard.
In this recipe, we will learn how to use condition variables to activate data processing in a separate thread as soon as the data is available.