[concurrency-interest] Single producer, single consumer: unexpected delays for producer

Jed Wesley-Smith jed at atlassian.com
Mon Aug 11 03:55:20 EDT 2008

Jed Wesley-Smith wrote:
> The above example uses a class called BooleanLatch that I have 
> discussed in previous threads on this list (basically a reusable 
> single count CountDownLatch), but I found that using Lock/Condition 
> wasn't a hell of a lot slower, particularly under high contention, and 
> the Lock version might have a couple of advantages in this particular 
> case as you can drain while holding the lock.

I should say that with high contention the Lock/Condition impl was a bit 
slower under Java6 (around 10%), and the BooleanLatch was significantly 
quicker under Java5 - about 30%. Under both JVMs the BooleanLatch is 
about twice as quick when uncontended.


More information about the Concurrency-interest mailing list