Pthreads is a standardized model for divideing a program into subtasks which can be run in parallel. We will repeat the example using Pthreads. The program starts with the main thread. A pointer to a structure of type thread attribute object. A pointer to routine at whichthe new thread will start executing A pointer to a parameter to be passed to the routine at which the new thread starts threads are created withou replicating an entire process.
Condition variables notify the waiting threads.
In absence of condition variables, threads would need to poll the variable to determine when it reaches a certain state. As usual we will illustrate the use of the Condition variable through an example. The main routine creates three threads. Two thread runs the increment routine and another thread starts the watch routine. It suspends the caller until another thread notifys through the signal.