Package com.ldtteam.structurize.util
Class ManualBarrier
java.lang.Object
com.ldtteam.structurize.util.ManualBarrier
A waitable primitive that is open/closed manually rather than counted like a
CyclicBarrier or Semaphore.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the barrier and requests all future threads to wait.voidopen()Opens the barrier and allows all currently-waiting and future threads to pass.voidwaitOne()Blocks the thread if the barrier is currently closed, until any other thread callsopen().
-
Constructor Details
-
ManualBarrier
public ManualBarrier(boolean open) Constructs the barrier.- Parameters:
open- true if the barrier is initially open (allow waiters to continue)
-
-
Method Details
-
waitOne
Blocks the thread if the barrier is currently closed, until any other thread callsopen().- Throws:
InterruptedException- if the thread is interrupted during the wait
-
open
public void open()Opens the barrier and allows all currently-waiting and future threads to pass. -
close
public void close()Closes the barrier and requests all future threads to wait.
-