app.util
Class Token

java.lang.Object
  extended by app.util.Token

public final class Token
extends java.lang.Object

A synchronization Token is essentially a binary semaphore, with acquire() as the potentially blocking P() operation, and release() as the potentially unblocking V() operation.


Method Summary
 void acquire()
          Acquires this token, blocking if necessary until it is available.
static Token newBlockedToken()
          Creates and returns a new token, initially "blocked", i.e.
static Token newUnblockedToken()
          Creates and returns a new token, initially "unblocked", i.e.
 void release()
          Releases this token, possibly unblocking a thread currently attempting to acquire() it.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

acquire

public final void acquire()
                   throws java.lang.InterruptedException
Acquires this token, blocking if necessary until it is available.

Throws:
java.lang.InterruptedException

release

public final void release()
                   throws java.lang.IllegalStateException
Releases this token, possibly unblocking a thread currently attempting to acquire() it.

Throws:
java.lang.IllegalStateException

newBlockedToken

public static final Token newBlockedToken()
Creates and returns a new token, initially "blocked", i.e. allocated.


newUnblockedToken

public static final Token newUnblockedToken()
Creates and returns a new token, initially "unblocked", i.e. unallocated.