if (currentWriter.equals(Thread.currentThread()))
if (Thread.currentThread().equals(currentWriter))
  protected void writeUnlock()  {    synchronized (documentCV)    {        if (currentWriter.equals(Thread.currentThread()))          {            currentWriter = null;            documentCV.notifyAll();          }    }  }