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.
-
Semaphore()
- This Semaphore class constructor is called to create an
instance of the semaphore class with semCount set initially
to zero.
-
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.
-
Signal()
- The Signal method causes the semCount to be incremented.
-
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.
Semaphore
public Semaphore()
- This Semaphore class constructor is called to create an
instance of the semaphore class with semCount set initially
to zero.
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.
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.
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