Semaphorepublic class Semaphore extends Object
Fields Summary |
---|
private SemaphoreLock | lock |
Constructors Summary |
---|
public Semaphore(int permits)Creates a Semaphore with the given number of permits.
lock = new SemaphoreLock(permits);
|
Methods Summary |
---|
public void | acquire()Acquires a permit from this semaphore, blocking until one is
available.
lock.acquire();
| public void | release()Releases a permit, returning it to the semaphore. If any
threads are blocking trying to acquire a permit, then one is
selected and given the permit that was just released. That
thread is re-enabled for thread scheduling purposes.
lock.release();
|
|