public boolean tryEnterIf ( Guard guard ) { if ( guard . monitor != this ) { throw new IllegalMonitorStateException ( ) ; } final ReentrantLock lock = this . lock ; if ( ! lock . tryLock ( ) ) { return false ; } boolean satisfied = false ; try { return satisfied = guard . isSatisfied ( ) ; } finally { if ( ! satisfied ) { lock . unlock ( ) ; } } }
Enters this monitor if it is possible to do so immediately and the guard is satisfied . Does not block acquiring the lock and does not wait for the guard to be satisfied .