I'm trying to understand how using this function doesn't cause a race condition. If I lock a mutex m and then call pthread_cond_wait(cond, m) m is now released and some other thread can lock it. When pthread_cond_signal(cond) is called, the first thread now locks the mutex now there are 2 threads running code between a lock/release on the same mutex. Am I missing something or should all code after the pthread_cond_wait be (I think this is the correct term) thread safe?