code: @Override
    public void run() {
      synchronized (lock) {
        if (!callables.hasNext()) {
          checkEnd();
          return;
        }
  
        for (int i = 0; i < parallelism && callables.hasNext(); i++) {
          setupNext(callables.next());
        }
      }
  
      future.whenCancelled(() -> {
        cancel = true;
        checkNext();
      });
    }
docs: coordinate thread.