Causes the current thread to wait until the latch has counted down to zero, unless the thread is {@linkplain Thread#interrupt interrupted}.
If the current count is zero then this method returns immediately.
If the current count is greater than zero then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happen:
- The count reaches zero due to invocations of the {@link #countDown} method; 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 waiting,
then {@link InterruptedException} is thrown and the current thread'sinterrupted status is cleared.
@throws InterruptedException if the current thread is interruptedwhile waiting