class SerializeReentrantCallsDirectExecutor implements Executor {

  @Override
  public void execute(Runnable task) {
    Preconditions.checkNotNull(task, "'task' must not be null.");
    if (!executing) {
      executing = true;
      try {
        task.run();
      } catch (Throwable t) {
        log.log(Level.SEVERE, "Exception while executing runnable " + task, t);
      } finally {
        if (taskQueue != null) {
          completeQueuedTasks();
        }
        executing = false;
      }
    } else {
      enqueue(task);
    }
  }

}