[concurrency-interest] Use of blocked queues

Doug Lea dl at cs.oswego.edu
Mon May 30 09:43:47 EDT 2005

Calum MacLean wrote:

> I can achieve this relatively easily directly, by using a common object for 
> synchronising around, and keeping a note of the number of readers.  

Except that the reader count will not include any thread currently
blocked on that lock waiting to get in while you are checking, which is
exactly the race condition you'd have otherwise. So, while you might
be able to reduce unnecessary events using something like this,
you can't eliminate them, and if this lock becomes highly contended,
you might find that it is faster overall to just unconditionally
issue events. Or maybe not. But I don't see anything that adding
any capability to java.util.concurrent would help with here.


More information about the Concurrency-interest mailing list