High performance barrier synchronization for Java

The jbarrier library provides a set of barrier algorithms for thread synchronization in Java. Compared to the CyclicBarrier shipped with Java SE, the jbarrier algorithms show superior performance for a number of use cases. Additionally, the jbarrier algorithms support global reductions. The jbarrier library is free software licensed under the GNU Lesser General Public License (LGPL), which is included in the download archive. We hope that jbarrier will be useful for you.


While developing the parallel wireless network simulator HiPWiNS in Java, we were in need of a barrier construct to repeatedly synchronize a number of threads participating in the simulation. We ran some tests using the CyclicBarrier from the java.util.concurrent package, but it turned out that the synchronization overhead was much higher than what was desired for our application. Therefore, we started to experiment with self-written implementations of various barrier algorithms and found that our simulator showed much better performance when using our own implementations.

Recently, we decided to extract the barrier implementations from our simulator and put them into a separate library, jbarrier, so that they can be used by other applications, too. In the process of creating the library, we added many optimizations and extensions to the different barrier implementations, and there may be more to come.

It is important to note that the jbarrier algorithms have been written for applications where the number of threads participating in the barrier synchronizations is not larger than the number of physical cores of the machine. A typical application of that kind is an expensive computation split into a pre-defined number of worker threads that have to synchronize frequently in order to exchange intermediate results. Having such applications in mind, our implementation makes heavy use of active waiting (spinning on atomic and volatile variables, etc.). Thus, its performance may decline severely if the number of threads participating in the barrier is higher than the number of physical cores.


Download undefinedjbarrier v1.0 (2010-09-09)

Additional resources

  • Performance: A series of benchmark results of jbarrier can be found here.


For questions and feedback regarding jbarrier please contact Patrick Peschlow.