@SuppressWarnings("BusyWait")
  private void waitUntilReadOrTimeout(int timeoutMillis, Thread newThread) {
    long started = System.currentTimeMillis();
    long deadline = started + timeoutMillis;

    boolean interrupted = false;
    try {
      while (!(myRef.get() != null || myExceptionRef.get() != null) && System.currentTimeMillis() < deadline) {
        Thread.sleep(10);
      }
    }
    catch (InterruptedException e) {
      interrupted = true;
    }
    finally {
      newThread.interrupt();
      if (interrupted) {
        Thread.currentThread().interrupt();
      }
    }
  }
@SuppressWarnings("BusyWait")
  private void waitUntilReadOrTimeout(int timeoutMillis, Thread newThread)