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 ?

Était-ce utile?

La 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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top