public boolean enterIfInterruptibly ( Guard guard ) throws InterruptedException { if ( guard . monitor != this ) { throw new IllegalMonitorStateException ( ) ; } final ReentrantLock lock = this . lock ; lock . lockInterruptibly ( ) ; boolean satisfied = false ; try { return satisfied = guard . isSatisfied ( ) ; } finally { if ( ! satisfied ) { lock . unlock ( ) ; } } }
Enters this monitor if the guard is satisfied . Blocks indefinitely acquiring the lock but does not wait for the guard to be satisfied and may be interrupted .