public class Semaphore
extends java.lang.Object
java.util.concurrent.Sempahore class.| Modifier and Type | Field and Description | 
|---|---|
| protected long | permitsCurrent number of available permits. | 
| Constructor and Description | 
|---|
| Semaphore(long initialPermits)Create a Semaphore with the given initial number of permits. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | acquire()Wait until a permit is available, and take one. | 
| boolean | attempt(long msecs)Wait at most msecs millisconds for a permit. | 
| long | permits()Return the current number of available permits. | 
| void | release()Release a permit. | 
| void | release(long n)Release N permits. | 
public Semaphore(long initialPermits)
public void acquire()
             throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic boolean attempt(long msecs)
                throws java.lang.InterruptedException
java.lang.InterruptedExceptionpublic void release()
public void release(long n)
release(n) is equivalent in effect to:
 for (int i = 0; i < n; ++i) release();But may be more efficient in some semaphore implementations.
java.lang.IllegalArgumentException - if n is negativepublic long permits()
Generated on June 8 2013