sleep.bridges

Class Semaphore


public class Semaphore
extends 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

void
P()
aquires this semaphore by attempting to decrement the count.
void
V()
increments this semaphore
long
getCount()
returns the current count data associated with this semaphore.
String
toString()
returns a nice string representation of this semaphore

Constructor Details

Semaphore

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

Method Details

P

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

V

public void V()
increments this semaphore

getCount

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

toString

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