code: private void executeTaskAsync() {
          final String taskId = currentTask.getId();
  
          ListenableFuture<?> future = taskExecutorService.submit(currentTask);
          pendingTasks.put(taskId, future);
  
          future.addListener(new Runnable() {
              @Override
              public void run() {
                  pendingTasks.remove(taskId);
              }
          }, MoreExecutors.sameThreadExecutor());
  
          hasCurrentTask = false;
      }
docs: Submits the task for future execution. Task is added to pending tasks
  and removed when the execution is done.