code: public synchronized boolean advanceTo(long endTime) {
      if (endTime < currentTime || runnables.isEmpty()) {
        currentTime = endTime;
        return false;
      }
  
      int runCount = 0;
      while (nextTaskIsScheduledBefore(endTime)) {
        runOneTask();
        ++runCount;
      }
      currentTime = endTime;
      return runCount > 0;
    }
docs: Run all runnables that are scheduled before the endTime.
  
  @param   endTime   Future time.
  @return  True if a runnable was executed.