documentCV.wait();
while (numReaders > 0 || currentWriter != null) { if (Thread.currentThread() == currentWriter) { if (notifyListeners) throw new IllegalStateException("Mutation during notify"); numWriters++; return;
  protected final void writeLock()  {    if (currentWriter != null && currentWriter.equals(Thread.currentThread()))      return;    synchronized (documentCV)      {        numWritersWaiting++;        while (numReaders > 0)          {            try              {                documentCV.wait();              }            catch (InterruptedException ie)              {                throw new Error("interruped while trying to obtain write lock");              }          }        numWritersWaiting --;        currentWriter = Thread.currentThread();      }  }