public synchronized void lockExclusive ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "lockExclusive" , this ) ; boolean interrupted = false ; // If another thread is attempting to lock exclusive, // wait for it to finish first. while ( ! tryLockExclusive ( ) ) { try { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Waiting to get exclusive lock" ) ; wait ( 1000 ) ; } catch ( InterruptedException e ) { // No FFDC code needed interrupted = true ; } } // Wait for existing locks to be released while ( iLockCount > 0 ) { try { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Waiting for lock count to reach 0 " + iLockCount ) ; wait ( 1000 ) ; } catch ( InterruptedException e ) { // No FFDC code needed interrupted = true ; } } if ( interrupted ) { Thread . currentThread ( ) . interrupt ( ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "lockExclusive" ) ; }
This method locks the mutex so no other lockers can get the lock .