public class Semaphore
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
capacity
Semaphore capacity, defined when the semaphore is created.
|
Constructor and Description |
---|
Semaphore(int capacity)
Creates a new semaphore with the given capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
acquire()
Locks on the semaphore object with no timeout
|
void |
acquire(double timeout)
Locks on the semaphore object until the provided timeout expires
|
protected void |
finalize()
Deletes this semaphore when the GC reclaims it
|
int |
getCapacity()
Returns the semaphore capacity
|
static void |
nativeInit()
Class initializer, to initialize various JNI stuff
|
void |
release()
Releases the semaphore object
|
boolean |
wouldBlock()
returns a boolean indicating it this semaphore would block at this very specific time
Note that the returned value may be wrong right after the
function call, when you try to use it...
|
protected final int capacity
public Semaphore(int capacity)
public void acquire(double timeout) throws TimeoutException
TimeoutException
- if the timeout expired before
the semaphore could be acquired.public void acquire()
public void release()
public boolean wouldBlock()
public int getCapacity()
protected void finalize()
finalize
in class java.lang.Object
public static void nativeInit()