final boolean tryWriteLock(){
  Thread current=Thread.currentThread();
  int c=getState();
  if (c != 0) {
    int w=exclusiveCount(c);
    if (w == 0 || current != getExclusiveOwnerThread())     return false;
    if (w == MAX_COUNT)     throw new Error("Maximum lock count exceeded");
  }
  if (!compareAndSetState(c,c + 1))   return false;
  setExclusiveOwnerThread(current);
  return true;
}

final boolean tryWriteLock ( ) { Thread current = Thread . currentThread ( ) ; int c = getState ( ) ; if ( c != 0 ) { int w = exclusiveCount ( c ) ; if ( w == 0 || current != getExclusiveOwnerThread ( ) ) return false ; if ( w == MAX_COUNT ) throw new Error ( "Maximum lock count exceeded" ) ; } if ( ! compareAndSetState ( c , c + 1 ) ) return false ; setExclusiveOwnerThread ( current ) ; return true ; }
performs trylock for write , enabling barging in both modes . this is identical in effect to tryacquire except for lack of calls to writershouldblock .
