public class Semaphore extends Object
| Constructor and Description |
|---|
Semaphore(int count)
Create a Semaphore.
|
| Modifier and Type | Method and Description |
|---|---|
void |
acquire()
Acquire the Semaphore.
|
void |
acquire(long timeOut)
Acquire the Semaphore.
|
void |
release()
Release the Semaphore.
|
boolean |
tryAcquire(long timeOut)
Acquire the Semaphore.
|
public Semaphore(int count)
count - semaphore countpublic void acquire()
throws InterruptedException
InterruptedException - exception during waitpublic void acquire(long timeOut)
throws TimeoutException,
InterruptedException
timeout amount of time expires.timeOut - amount of time (millis) to wait before returning (unless operation completes before)TimeoutException - wait timed out exceptionInterruptedException - exception during waitpublic boolean tryAcquire(long timeOut)
throws InterruptedException
timeout amount of time expires.timeOut - amount of time (millis) to wait before returning (unless operation completes before)true if the semaphore acquired, false if timeout occurredInterruptedException - exception during waitpublic void release()
Copyright © 2005–2025 Onix Solutions. All rights reserved.