sleep.bridges
Class Semaphore

java.lang.Object
  extended by sleep.bridges.Semaphore

public class Semaphore
extends java.lang.Object

A sleep synchronization primitive. I know Java 1.5.0 has this stuff but since Sleep targets 1.4.2 I get to provide my own. How exciting.


Constructor Summary
Semaphore(long initialCount)
          initializes this semaphore with the specified initial count
 
Method Summary
 long getCount()
          returns the current count data associated with this semaphore.
 void P()
          aquires this semaphore by attempting to decrement the count.
 java.lang.String toString()
          returns a nice string representation of this semaphore
 void V()
          increments this semaphore
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Semaphore

public Semaphore(long initialCount)
initializes this semaphore with the specified initial count

Method Detail

P

public void P()
aquires this semaphore by attempting to decrement the count. blocks if the count is not > 0 (prior to decrement).


getCount

public long getCount()
returns the current count data associated with this semaphore. note that this value is volatile


V

public void V()
increments this semaphore


toString

public java.lang.String toString()
returns a nice string representation of this semaphore

Overrides:
toString in class java.lang.Object