Package com.groiss.ds

Class CountedSemaphore

java.lang.Object
java.util.concurrent.Semaphore
com.groiss.ds.CountedSemaphore
All Implemented Interfaces:
Serializable

public class CountedSemaphore extends Semaphore
A CountedSemaphore (from Dijkstra) where waiting threads are handled in FIFO order. Moreover you can specify the amount of threads waiting for the resource. If the waiting queue is full the next caller will receive an QueueFullException.
See Also:
  • Constructor Details

    • CountedSemaphore

      public CountedSemaphore(int threadsRunning)
      Construct a new semaphore.
      Parameters:
      threadsRunning - how many threads can go into the critical section.
    • CountedSemaphore

      public CountedSemaphore(int threadsRunning, int threadsWaiting)
      Construct a new semaphore.
      Parameters:
      threadsRunning - how many threads can go into the critical section.
      threadsWaiting - how many threads may wait.
  • Method Details