public void testDeadlock49178() throws Exception {
    // open the document
    final StyledDocument docu = support.openDocument();

    // start closing it
    Thread closing =
        new Thread(
            new Runnable() {
              public void run() {
                support.close(false); // will block in notifyUnmodified()
                closingDone = true;
              }
            });
    closing.start();

    Thread processing =
        new Thread(
            new Runnable() {
              boolean second = false;

              public void run() {
                if (!second) {
                  second = true;
                  docu.render(this);
                  //                    NbDocument.runAtomic(docu, this);
                } else { // inside readLock
                  support.createPositionRef(0, Position.Bias.Forward);
                  processingDone = true;
                }
              }
            });

    synchronized (waitLock) {
      while (!inWait) waitLock.wait();
    }

    processing.start();

    Thread.sleep(1000);
    synchronized (waitLock) {
      shouldWait = false;
      waitLock.notifyAll();
    }

    closing.join(10000);
    processing.join(10000);
    assertNull("No exception thrown", exception);
    assertTrue("Closing thread finished", closingDone);
    assertTrue("Processing thread finished", processingDone);
  }