code: private synchronized void maybeRun() {
          if (inprogress==null && pending!=null) {
              base.submit(new Callable<Void>() {
                  @Override
                  public Void call() throws Exception {
                      synchronized (AtmostOneTaskExecutor.this) {
                          // everyone who submits after this should form a next batch
                          inprogress = pending;
                          pending = null;
                      }
  
                      try {
                          inprogress.set(task.call());
                      } catch (Throwable t) {
                          LOGGER.log(Level.WARNING, null, t);
                          inprogress.setException(t);
                      } finally {
                          synchronized (AtmostOneTaskExecutor.this) {
                              // if next one is pending, get that scheduled
                              inprogress = null;
                              maybeRun();
                          }
                      }
                      return null;
                  }
              });
          }
      }
docs: If {@link #pending} is non-null (meaning someone requested the task to be kicked),
  but {@link #inprogress} is null (meaning none is executing right now),
  get one going.