Thank you for your answer. I implemented the code exactly the same way (with the condition variable) as in the sample code. But it worked only after I replaced PTHREAD_MUTEX_ERRORCHECK with PTHREAD_MUTEX_DEFAULT. The main thing is that it works now! :-)