Package org.jboss.util
Class Semaphore
- java.lang.Object
-
- org.jboss.util.Semaphore
-
- All Implemented Interfaces:
Sync
- Direct Known Subclasses:
WaitSemaphore
public class Semaphore extends java.lang.Object implements Sync
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- Version:
- $Revision$
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classSemaphore.Info
-
Field Summary
Fields Modifier and Type Field Description private static longDEADLOCK_TIMEOUTprivate intm_allowedprivate static booleanm_debugprivate java.util.Mapm_logMapprivate intm_users
-
Constructor Summary
Constructors Constructor Description Semaphore(int allowed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquire()Acquires this syncintgetUsers()protected voidlogAcquire()protected voidlogDeadlock()protected voidlogRelease()voidrelease()Releases this syncjava.lang.StringtoString()protected booleanwaitImpl(java.lang.Object lock)
-
-
-
Field Detail
-
DEADLOCK_TIMEOUT
private static final long DEADLOCK_TIMEOUT
- See Also:
- Constant Field Values
-
m_debug
private static final boolean m_debug
- See Also:
- Constant Field Values
-
m_users
private int m_users
-
m_allowed
private int m_allowed
-
m_logMap
private java.util.Map m_logMap
-
-
Method Detail
-
getUsers
public int getUsers()
-
acquire
public void acquire() throws java.lang.InterruptedExceptionDescription copied from interface:SyncAcquires this sync- Specified by:
acquirein interfaceSync- Throws:
java.lang.InterruptedException- See Also:
Sync.release()
-
release
public void release()
Description copied from interface:SyncReleases this sync- Specified by:
releasein interfaceSync- See Also:
Sync.acquire()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
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()
-
-