Question

I want a barrier with a dynamic number of parties in java. I came across Phaser, but this solution is for java 7 which I unfortunately cannot use.

Is there some solution for java 6. How should I satisfy the need for having a barrier with a variable number of waiters ?

Was it helpful?

Solution

You really want to use a Phaser. There is a backport for Phaser that you can use in Java 6. Download it from JSR 166y backport

OTHER TIPS

What about CyclicBarrier?

like said in Phaser:

similar in functionality to CyclicBarrier and CountDownLatch but supporting more flexible usage.

is there some functionality you need that missing in those classes?

Edit: After some googling I don't see something like this, Don't know how complicated your problem, and how you should synchronized all your members in the barrier, but you can implement some simple parties sync with hierarchy of CyclicBarrier

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top