boolean waitFor(long timeoutMS) {
    assertCorrectThread();
    synchronized (myQueue) {
      long start = System.currentTimeMillis();

      while (isProcessing) {
        long rest = timeoutMS - (System.currentTimeMillis() - start);

        if (rest <= 0) return !isProcessing;

        try {
          myQueue.wait(rest);
        }
        catch (InterruptedException e) {
          //ok
        }
      }

      return true;
    }
  }
boolean waitFor(long timeoutMS)