Does add() on LinkedBlockingQueue notify waiting threads?

Posted by obvio171 on Stack Overflow See other posts from Stack Overflow or by obvio171
Published on 2010-06-06T23:42:16Z Indexed on 2010/06/06 23:52 UTC
Read the original article Hit count: 313

Filed under:
|
|
|

I have a consumer thread taking elements from a LinkedBlockingQueue, and I make it sleep manually when it's empty. I use peek() to see if the queue empty because I have to do stuff because sending the thread to sleep, and I do that with queue.wait().


So, when I'm in another thread and add()an element to the queue, does that automatically notify the thread that was wait()ing on the queue?

© Stack Overflow or respective owner

Related posts about java

Related posts about multithreading