code: public int runAll() {
      int numTasksRun = 0;
      if (Thread.currentThread().equals(executorThread)) {
        Logger.info("ignoring request to execute task - called from executor's own thread");
        return numTasksRun;
      }
      while (hasQueuedTasks()) {
        runNext();
        numTasksRun++;
      }
      return numTasksRun;
    }
docs: Execute all posted tasks and block until they are complete.
  
  @return the number of tasks executed