[concurrency-interest] JCiP Condition Queues

Tim Peierls tim at peierls.net
Sat Nov 4 09:18:00 EST 2006

On 11/4/06, Alexandru Popescu <the.mindstorm.mailinglist at gmail.com> wrote:
> For me it looks like the code can be written like:
> [code]
> if(wasEmpty) {
>    notify(); // was empty and now I have 1 element => only 1 consumer can
> really do something
> }
> else {
>    notifyAll(); // there is no problem to awake multiple threads... we
> have plenty of elements
> }
> [/code]

"Only one consumer can really do something" but there's no guarantee that
the thread that is woken up will be a consumer thread, i.e., a thread doing
take() rather than put(). That's the reason for the "uniform waiters"
condition on p.303.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20061104/a0b0c6c0/attachment.html 

More information about the Concurrency-interest mailing list