Rather than continuously checking to see if my queue has a message, I provide a sleep function that waits 30 seconds in the event that no message was retrieved.
我没有不断检查看我的队列是否有消息,我提供了一个休眠函数,如没有检索到消息就等待30秒。
2
h; it puts the calling process to sleep killably in queue until the condition evaluates to true.
它将处于可终止睡眠状态的调用进程置于 queue 中,直到 condition 等于 true。
3
All threads that go to sleep from calling pthread_mutex_lock on an already-locked mutex will "queue up" for access to that mutex.