MultiThreading
|
Modules | |
Basic functionality of condition variables - unsafe usage | |
Using condition variables - the safe way | |
Examples | |
Within multithreaded environments a system's reaction to some internal or external trigger may consist of a series of small steps executed by multiple threads. The steps may be executed at least partly in parallel. Within such a scenario there is often the need that a thread has to wait until some preprocessing has reached some state before he can start or proceed with his own processing.
A simple approach for the waiting thread might be polling: he repeatedly checks some shared data until he recognizes that the data's state allows to start his own processing. If the state is not yet reached he sleeps for a small time interval and then repeats the check.
The typical disadvantages of this approach are:
To avoid these disadvantages you can use