code: private void waitForEventOrTimeout() throws InterruptedException {
          long remainingWait = timeout - timeWaited;
          long millisToWait = remainingWait / 1000000;
          int nanosToWait = (int) (remainingWait % 1000000);
          wait(millisToWait, nanosToWait);
      }
docs: Wait for a notification or a timeout - may wake spuriously.