org.jboss.util
Class Semaphore

java.lang.Object
  extended byorg.jboss.util.Semaphore
All Implemented Interfaces:
Sync (src)
Direct Known Subclasses:
BeanSemaphore (src) , WaitSemaphore (src)

public class Semaphore
extends java.lang.Object
implements Sync (src)

Semaphore that can allow a specified number of threads to enter, blocking the others. If the specified number of threads is 1, it acts as an exclusive semaphore and can be used instead of synchronized blocks


Constructor Summary
Semaphore(int allowed)
           
 
Method Summary
 void acquire()
          Acquires this sync
 int getUsers()
           
protected  void logAcquire()
           
protected  void logDeadlock()
           
protected  void logRelease()
           
 void release()
          Releases this sync
 java.lang.String toString()
           
protected  boolean waitImpl(java.lang.Object lock)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Semaphore

public Semaphore(int allowed)
Method Detail

getUsers

public int getUsers()

acquire

public void acquire()
             throws java.lang.InterruptedException
Description copied from interface: Sync (src)
Acquires this sync

Specified by:
acquire in interface Sync (src)
Throws:
java.lang.InterruptedException
See Also:
Sync.release()

release

public void release()
Description copied from interface: Sync (src)
Releases this sync

Specified by:
release in interface Sync (src)
See Also:
Sync.acquire()

toString

public java.lang.String toString()

waitImpl

protected boolean waitImpl(java.lang.Object lock)
                    throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

logAcquire

protected void logAcquire()

logDeadlock

protected void logDeadlock()

logRelease

protected void logRelease()