阅读背景:

java和threads:中断的异常以及如何正确使用BlockingQueue的take()方法

来源:互联网 

What exactly happens when there is nothing on the queue and a take() is called. The API says the method will wait but does that mean the CPU spins checking for empty/not empty until an item is on the queue or does it mean that the thread yields and will be awoken by an interrupt? If it is the case of the former, I would probably want to see if the queue is empty and if it is call thread.yield() to give up processor time. My question is really do I need to call yield or does some inner mechanism handle that for me?What exactly happens when there is nothing on t




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

分享到: