[concurrency-interest] CyclicBarrier / Count Down Latch

Doug Lea dl at cs.oswego.edu
Mon Apr 20 11:44:40 EDT 2009


javamann at cox.net wrote:
> Howdy, I have an application that generates an unknown amount of threads at
> startup (via JMX MLet) and I was looking for a way to block all the threads
> at a certain point and then 'release' them to continue. I looked at the
> CyclicBarrier and CountDownLatch but they require you know the number of
> threads ahead of time. Currently I am just using a 'global' Condition for
> them to acquire and then Signal them all to continue. This seems like a hack
> and I am hoping there is a better way to accomplish this. Any Ideas?
> 

This is one of the long-missing usages that we addressed in Phasers --
http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/Phaser.html
This is targeted for Java7 but available now in jsr166y package --
See http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
for jars, sources, etc

-Doug






More information about the Concurrency-interest mailing list