org.jboss.util
Class Semaphore

java.lang.Object
  |
  +--org.jboss.util.Semaphore
All Implemented Interfaces:
Sync

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: 1.1 $
Author:
Simone Bordet (simone.bordet@compaq.com)

Constructor Summary
Semaphore(int users)
           
 
Method Summary
 void acquire()
          Acquires this sync
 boolean attempt(long msecs)
          Attempts to acquire this sync in msecs milliseconds; if succeeds in acquiring it, returns true, otherwise returns false.
protected  void logAcquire()
           
protected  void logDeadlock()
           
protected  void logRelease()
           
 void release()
          Releases this sync
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Semaphore

public Semaphore(int users)
Method Detail

acquire

public void acquire()
             throws java.lang.InterruptedException
Description copied from interface: Sync
Acquires this sync
Specified by:
acquire in interface Sync
Following copied from interface: org.jboss.util.Sync
See Also:
Sync.release()

attempt

public boolean attempt(long msecs)
                throws java.lang.InterruptedException
Description copied from interface: Sync
Attempts to acquire this sync in msecs milliseconds; if succeeds in acquiring it, returns true, otherwise returns false.
Specified by:
attempt in interface Sync
Following copied from interface: org.jboss.util.Sync
See Also:
Sync.acquire()

release

public void release()
Description copied from interface: Sync
Releases this sync
Specified by:
release in interface Sync
Following copied from interface: org.jboss.util.Sync
See Also:
Sync.acquire()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

logAcquire

protected void logAcquire()

logDeadlock

protected void logDeadlock()

logRelease

protected void logRelease()


Copyright © 2000 The JBoss Organization. All Rights Reserved.