Acquires a permit from this semaphore, blocking until one is available or this thread is interrupted.
If a permit is immediately available, this method returns immediately, reducing the number of available permits in the semaphore by one.
If no permit is available, then the current thread becomes disabled and lies dormant until one of the following occurs:
- Some other party invokes the {@link #release()} method for this semaphore and the current partyis the next to be assigned a permit
- Some other party leaves the Semaphore abruptly, as in a node failure scenario.
- Some other thread interrupts the current thread
If the current thread:
- has its interrupted status set on entry to this method or
- is interrupted while waiting for a permit
then an InterruptedException is thrown and the current thread's interrupted status is cleared.
@throws InterruptedException if the current thread is interrupted