wait and notify in C/C++ shared memory
问题 How to wait and notify like in Java In C/C++ for shared memory between two or more thread?I use pthread library. 回答1: Instead of the Java object that you would use to wait/notify, you need two objects: a mutex and a condition variable. These are initialized with pthread_mutex_init and pthread_cond_init . Where you would have synchronized on the Java object, use pthread_mutex_lock and pthread_mutex_unlock (note that in C you have to pair these yourself manually). If you don't need to wait