Class simu.util.Semaphore
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class simu.util.Semaphore

java.lang.Object
   |
   +----simu.util.Semaphore

public class Semaphore
extends Object
Version:
1.0 27-Mar-97
Author:
Andre Campeau

The Semaphore class implements a simple counting semaphore. All methods are synchronized, meaning that the Semaphore class is actually a monitor. Calling threads wait for access to shared resources, which in this case is the semCount class variable.

The methods are as follows:
- Wait
- Signal
For more information, see the method descriptions included with the methods.

The behaviour of the Semaphore class is that of a counting semaphore, which means that calls to Wait() will cause the caller to block if the semCount is zero, and to decrement the semCount if it is greater than zero. Calls to Signal() will increment the semCount.


Constructor Index

 o Semaphore()
This Semaphore class constructor is called to create an instance of the semaphore class with semCount set initially to zero.
 o Semaphore(int)
This Semaphore class constructor is called to create an instance of the semaphore class with semCount set initially to the value specified by the SemCount parameter.

Method Index

 o Signal()
The Signal method causes the semCount to be incremented.
 o Wait()
The Wait method causes the caller to block if the semCount is zero, and to decrement the semCount if it is greater than zero.

Constructors

 o Semaphore
  public Semaphore()
This Semaphore class constructor is called to create an instance of the semaphore class with semCount set initially to zero.
 o Semaphore
  public Semaphore(int SemCount)
This Semaphore class constructor is called to create an instance of the semaphore class with semCount set initially to the value specified by the SemCount parameter.
Parameters:
SemCount - The initial semaphore count.

Methods

 o Wait
  public synchronized void Wait()
The Wait method causes the caller to block if the semCount is zero, and to decrement the semCount if it is greater than zero. The method is synchronized to provide mutual exclusion protection.
 o Signal
  public synchronized void Signal()
The Signal method causes the semCount to be incremented. If any threads are waiting for a signal, they will be notified and moved to the ready-to-run queue.

All Packages  Class Hierarchy  This Package  Previous  Next  Index