monitor
Class Semaphore

java.lang.Object
  extended by monitor.Semaphore

public class Semaphore
extends java.lang.Object

A FIFO semaphore.

Version:
2.0
Author:
Theodore S. Norvell

Constructor Summary
Semaphore(int initial_value)
          Initialize the semaphore to a value greater or equal to 0
 
Method Summary
 void acquire()
          The P operation.
 void acquire(int priority)
          The P operation with a priority.
 void release()
          The V operation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Semaphore

public Semaphore(int initial_value)
Initialize the semaphore to a value greater or equal to 0

Method Detail

acquire

public void acquire()
The P operation. If two threads are blocked at the same time, they will be served in FIFO order. sem.acquire() is equivalent to acquire( Integer.MAX_VALUE ).


acquire

public void acquire(int priority)
The P operation with a priority.

Parameters:
priority - The larger the integer, the less urgent the priority. If two thread are waiting with equal priority, they will complete acquire in FIFO order.

release

public void release()
The V operation