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