Class ManualBarrier

java.lang.Object
com.ldtteam.structurize.util.ManualBarrier

public final class ManualBarrier extends Object
A waitable primitive that is open/closed manually rather than counted like a CyclicBarrier or Semaphore.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ManualBarrier(boolean open)
    Constructs the barrier.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the barrier and requests all future threads to wait.
    void
    Opens the barrier and allows all currently-waiting and future threads to pass.
    void
    Blocks the thread if the barrier is currently closed, until any other thread calls open().

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public void waitOne() throws InterruptedException
      Blocks the thread if the barrier is currently closed, until any other thread calls open().
      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.