I have a program in Java that performs some computation in parallel. I can either run it on a single machine or using multiple different machines.
When executing on a single machine, thread synchronization is successfully achieved by using CyclicBarrier class from java.util.concurrent.CyclicBarrier package. The idea is that all the threads must wait for the other threads to arrive at the same point before proceeding with the computation.
When executing on multiple different machines, inter process communication is implemented via RMI (Remote Method Invocation). I have the same problem on this situation and I want the threads of these processes to wait for the others to arrive at the same point before continuing. I cannot use a shared CyclicBarrier object between the different processes because this class is not serializable.
What are my alternatives to get this barrier behavior on threads executing on different processes on multiple machines?
Thanks
You don't need to pass a CyclicBarrier between processes. You can do an RMI call which in turn uses a CyclicBarrier. I suggest you look at HazelCast at it support distributed Lock
and many other collections.
IMHO I would reconsider whether you really need all the processes to check point and find a way to avoid needing this in the first place.