Acquires a permit, if one is available and returns immediately, reducing the number of available permits by one.
If no permit is available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
- Some other thread invokes one of the {@link #release} methods for thissemaphore and the current thread is next to be assigned a permit;
- This ISemaphore instance is destroyed; or
- Some other thread {@linkplain Thread#interrupt interrupts}the current thread.
If the current thread:
- has its interrupted status set on entry to this method; or
- is {@linkplain Thread#interrupt interrupted} while waitingfor a permit,
then {@link InterruptedException} is thrown and the current thread'sinterrupted status is cleared.
@throws InterruptedException if the current thread is interrupted
@throws IllegalStateException if hazelcast instance is shutdown while waiting