public final void lockForWriteInterruptibly ( L locker ) throws InterruptedException { if ( Thread . interrupted ( ) ) { throw new InterruptedException ( ) ; } if ( ! tryLockForWrite ( locker ) ) { Result upgradeResult = lockForUpgradeInterruptibly_ ( locker ) ; if ( ! tryLockForWrite ( locker ) ) { lockForWriteQueuedInterruptibly ( locker , addWriteWaiter ( ) ) ; } if ( upgradeResult == Result . ACQUIRED ) { // clear upgrade state bit to indicate automatic upgrade while ( ! clearUpgradeLock ( mState ) ) { } } else { // undo automatic upgrade count increment mUpgradeCount -- ; } } }
Acquire an exclusive write lock possibly blocking until interrupted .