阅读背景:

在生产者 - 消费者情境中使用条件变量

来源:互联网 

I'm trying to learn about condition variables and how to use it in a producer-consumer situation. I have a queue where one thread pushes numbers into the queue while another thread popping numbers from the queue. I want to use the condition variable to signal the consuming thread when there is some data placed by the producing thread. The problem is there are times (or most times) that it only pushes up to two items into the queue then hangs. I have indicated in the produce() function where it stops when running in debug mode. Can anyone help me point out why this is happening?I'm trying to learn about condition variables a




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: