org.apache.avalon.excalibur.concurrent
Class Semaphore

java.lang.Object
  |
  +--org.apache.avalon.excalibur.concurrent.Semaphore
All Implemented Interfaces:
Sync
Direct Known Subclasses:
Mutex

public class Semaphore
extends java.lang.Object
implements Sync

Since:
4.0
Version:
CVS $Revision: 1.4 $ $Date: 2001/12/11 09:53:28 $

Constructor Summary
Semaphore(long tokens)
           
 
Method Summary
 void acquire()
          Aquire access to resource.
 boolean attempt(long msecs)
          Aquire access to resource.
 void release()
          Release lock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Semaphore

public Semaphore(long tokens)
Method Detail

acquire

public void acquire()
             throws java.lang.InterruptedException
Description copied from interface: Sync
Aquire access to resource. This method will block until resource aquired.
Specified by:
acquire in interface Sync
Following copied from interface: org.apache.avalon.excalibur.concurrent.Sync
Throws:
java.lang.InterruptedException - if an error occurs

release

public void release()
Description copied from interface: Sync
Release lock.
Specified by:
release in interface Sync

attempt

public boolean attempt(long msecs)
                throws java.lang.InterruptedException
Description copied from interface: Sync
Aquire access to resource. This method will block for a maximum of msec.
Specified by:
attempt in interface Sync
Following copied from interface: org.apache.avalon.excalibur.concurrent.Sync
Parameters:
msec - the duration to wait for lock to be released
Returns:
true if lock aquired, false on timeout
Throws:
java.lang.InterruptedException - if an error occurs


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.