jsat.utils.concurrent
Class TreeBarrier
- java.lang.Object
-
- jsat.utils.concurrent.TreeBarrier
-
public class TreeBarrier extends java.lang.ObjectTree Barrier is a barrier that requires only log(n) communication for barrier with n threads. To use this barrier, each thread must know its own unique ID that is sequential in [0, number of threads)
NOTE: The Tree Barrier implementation is not safe for accessing multiple times in a row. If accessed while some threads are still attempting to exit, corruption and deadlock can occur. If needed, two TreeBarriers can be used by alternating back and forth.
-
-
Constructor Summary
Constructors Constructor and Description TreeBarrier(int parties)Creates a new Tree Barrier for synchronization
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidawait(int ID)Waits for all threads to reach this barrier.
-
-
-
Constructor Detail
-
TreeBarrier
public TreeBarrier(int parties)
Creates a new Tree Barrier for synchronization- Parameters:
parties- the number of threads that must arrive to synchronize
-
-
Method Detail
-
await
public void await(int ID) throws java.lang.InterruptedExceptionWaits for all threads to reach this barrier.- Parameters:
ID- the id of the thread attempting to reach the barrier.- Throws:
java.lang.InterruptedException- if one of the threads was interrupted while waiting on the barrier
-
-
DataMelt 3.0 © DataMelt by jWork.ORG