private boolean alienReadLocksHeld ( ) { if ( tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "alienReadLocksHeld" , this ) ; boolean locksHeld = false ; //if there is more than one thread holding read locks then return true if ( readerThreadCount > 1 ) { locksHeld = true ; } //if there is exactly one thread holding a read lock... else if ( readerThreadCount == 1 ) { //check if it is the current thread holding that lock Thread currentThread = Thread . currentThread ( ) ; LockCount count = ( LockCount ) readerThreads . get ( currentThread ) ; //if the current thread does not hold any locks then return true since //it must be a different thread. locksHeld = ( count == null || count . count == 0 ) ; } //if there are no threads holding read locks then return false (default) if ( tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "alienReadLocksHeld" , new Boolean ( locksHeld ) ) ; return locksHeld ; }
The mutex must be help before calling this method .