Causes the current thread to wait until the latch has counted down to zero, unless the thread is {@link Thread#interrupt interrupted}.
If the current {@link #getCount count} is zero then this methodreturns immediately.
If the current {@link #getCount count} is greater than zero thenthe 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 {@link Thread#interrupt interrupts} the currentthread.
If the current thread:
- has its interrupted status set on entry to this method; or
- is {@link 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.