Not locking mutex for pthread_cond_timedwait and pthread_cond_signal ( on Linux )
问题 Is there any downside to calling pthread_cond_timedwait without taking a lock on the associated mutex first, and also not taking a mutex lock when calling pthread_cond_signal ? In my case there is really no condition to check, I want a behavior very similar to Java wait(long) and notify(). According to the documentation, there can be "unpredictable scheduling behavior". I am not sure what that means. An example program seems to work fine without locking the mutexes first. 回答1: The first is