public interface Semaphore
Modifier and Type | Interface and Description |
---|---|
static class |
Semaphore.Standard |
Modifier and Type | Method and Description |
---|---|
void |
acquire(int acquire)
Take permits, waiting indefinitely until available
|
void |
acquireThrowUncheckedOnInterrupt(int acquire)
Take permits, waiting indefinitely until available
|
int |
drain()
set the number of permits in this semaphore to zero
|
static Semaphore |
newFairSemaphore(int permits)
Factory method used to capture and redirect instantiations for simulation
Construct a fair Semaphore initially holding the specified number of permits
|
static Semaphore |
newSemaphore(int permits)
Factory method used to capture and redirect instantiations for simulation
Construct an unfair Semaphore initially holding the specified number of permits
|
int |
permits() |
void |
release(int permits)
Increase the number of available permits and signal any waiters that may be served by the release
|
boolean |
tryAcquire(int acquire)
Try to take permits, returning immediately
|
boolean |
tryAcquire(int acquire,
long time,
java.util.concurrent.TimeUnit unit)
Try to take permits, waiting up to timeout
|
boolean |
tryAcquireUntil(int acquire,
long nanoTimeDeadline)
Try to take permits, waiting until the deadline
|
int permits()
int drain()
void release(int permits)
boolean tryAcquire(int acquire)
boolean tryAcquire(int acquire, long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
java.lang.InterruptedException
- if interruptedboolean tryAcquireUntil(int acquire, long nanoTimeDeadline) throws java.lang.InterruptedException
java.lang.InterruptedException
- if interruptedvoid acquire(int acquire) throws java.lang.InterruptedException
java.lang.InterruptedException
- if interruptedvoid acquireThrowUncheckedOnInterrupt(int acquire) throws UncheckedInterruptedException
UncheckedInterruptedException
- if interruptedstatic Semaphore newSemaphore(int permits)
static Semaphore newFairSemaphore(int permits)
Copyright © 2009-2022 The Apache Software Foundation