Class Barrier

java.lang.Object
jromp.parallel.Barrier

public class Barrier extends Object
A barrier is a synchronization construct that allows multiple threads to wait for each other at a common point.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Barrier(String name, int count)
    Constructs a barrier with the specified name and count.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Causes the current thread to wait until all threads have reached the barrier.
    int
    Returns the number of threads that must reach the barrier before they can continue.
    int
    Returns the number of threads that have reached the barrier.
    Returns the name of the barrier.
    boolean
    Returns a flag to indicate whether the threads are waiting at the barrier.
    void
    Resets the barrier.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Barrier

      public Barrier(String name, int count)
      Constructs a barrier with the specified name and count.
      Parameters:
      name - the name of the barrier.
      count - the number of threads that must reach the barrier before they can continue.
  • Method Details

    • getName

      public String getName()
      Returns the name of the barrier.
      Returns:
      the name of the barrier.
    • getCount

      public int getCount()
      Returns the number of threads that must reach the barrier before they can continue.
      Returns:
      the number of threads that must reach the barrier before they can continue.
    • getCurrentCount

      public int getCurrentCount()
      Returns the number of threads that have reached the barrier.
      Returns:
      the number of threads that have reached the barrier.
    • isWaiting

      public boolean isWaiting()
      Returns a flag to indicate whether the threads are waiting at the barrier.
      Returns:
      a flag to indicate whether the threads are waiting at the barrier.
    • reset

      public void reset()
      Resets the barrier. This method is called after all threads have reached the barrier. It resets the current count and the waiting flag.
    • await

      public void await()
      Causes the current thread to wait until all threads have reached the barrier.
    • toString

      public String toString()
      Overrides:
      toString in class Object