Javamex

Java discussion forum to accompany the Javamex web site.

A new section of the Javamex web site looks at Java's CyclicBarrier class. This class, like CountDownLatch, helps in the coordination of threads in parallel operations. However, CyclicBarrier has some additional interesting properties.

The first is that an instance of CyclicBarrier can be re-used. In other words, it is suitable for iterative operations, or ones that take place in several stages. We show the example of a parallel sort which takes place in three stages.

Another interesting feature is that it allows interruptions to be propagated to all threads involved in the operation. This can be useful in particular if a "controller" thread is also participating in the barrier operation, since it can then detect if an error has occurred.

Views: 99

Reply to This

© 2024   Created by Neil Coffey.   Powered by

Badges  |  Report an Issue  |  Terms of Service