question: synchronized public boolean writeRequestImmediate ( ) { if ( writerLocks . size ( ) == 0 && currentReaders == 0 && currentWriters == 0 ) { ++ currentWriters ; return true ; } return false ; }
target:  This version of the write request returns false immediately (without blocking) if any read or write operations are in progress and a write isn't safe; otherwise, it returns true and acquires the resource. Use it like this: public void write() {  if( lock.writeRequestImmediate() ) { try {  // do the write operation here } finally { lock.writeDone(); } }else { // couldn't write safely. } }