关于pthread_cond_wait函数为何需要使用while循环,或者为何不使用if条件判断问题,经过Google后发现网上有不少已说明,这里给出自己的说明:
该函数的定义,可参考http://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_cond_wait.html,有详细的说明,把其中一段拿出来开始谈谈为何需要使用while循环:
If a signal is delivered to a thread waiting for a condition variable, upon return from the signal handler the thread resumes waiting for the condition variable as if it was not interrupted, or it returns zero due to spurious wakeup.
这里提到了两个原因:(1)it was not interrupted;&n