All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class eduni.simjava.Semaphore

java.lang.Object
   |
   +----eduni.simjava.Semaphore

public class Semaphore
extends Object
This is a counting semaphore class. It is used internally by the Sim_system to synchronise the running of the threaded Sim_entities. It should not be needed in user simulations.

See Also:
Sim_system

Constructor Index

 o Semaphore()
Allocate a new Semaphore object, with an initial count of zero.
 o Semaphore(int)
Allocates a new Semaphore object, with a given initial count.

Method Index

 o p()
Try to obtain the Semaphore.
 o v()
Free the Semaphore, by incrementing the internal count.

Constructors

 o Semaphore
 public Semaphore()
Allocate a new Semaphore object, with an initial count of zero.

 o Semaphore
 public Semaphore(int count)
Allocates a new Semaphore object, with a given initial count.

Parameters:
count - The initial count of the semaphore.

Methods

 o p
 public synchronized void p()
Try to obtain the Semaphore. If the count is above zero, the function decrements it, then return so the calling thread can continue. If the count is zero then the calling thread is suspended until it becomes non-zero.

 o v
 public synchronized void v()
Free the Semaphore, by incrementing the internal count.


All Packages  Class Hierarchy  This Package  Previous  Next  Index