Class Semaphore

java.lang.Object
  |
  +--Semaphore

public class Semaphore
extends java.lang.Object

Uses Java monitor primitives to implement semaphore. $RCSfile: Semaphore.java,v $


Constructor Summary
Semaphore()
          Default constructor, initializes to 0.
Semaphore(int i)
          Constructor with initialization.
 
Method Summary
 void P()
          Acquires the semaphore: < await(val > 0) val = val - 1 >
 void V()
          Releases the semaphore: < val = val + 1 >
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Semaphore

public Semaphore(int i)
Constructor with initialization.

Parameters:
i - Initial value for semaphore (>= 0)

Semaphore

public Semaphore()
Default constructor, initializes to 0.

Method Detail

V

public void V()
Releases the semaphore: < val = val + 1 >


P

public void P()
       throws java.lang.InterruptedException
Acquires the semaphore: < await(val > 0) val = val - 1 >

Throws:
java.lang.InterruptedException