The main problem is making sure one thread is currently blocked with a pthread_cond_wait () when the other thread calls pthread_cond_signal (). Sometimes it happens that way, but sometimes ...