@Override
  public void execute(DriverTask task) throws InterruptedException {
    task.lock();
    try {
      // If this task is already in an end state, it means that the resource releasing will be
      // handled by other threads, we don't care anymore.
      if (task.isEndState()) {
        return;
      }
    } finally {
      task.unlock();
    }

    // If this task has not reached the time limit, we can wait for some time.
    // SlEEP_BOUND ensures that DriverTaskTimeoutSentinelThread won't sleep for too long when the
    // waitTime of the task is long.
    long waitTime = Math.min(task.getDDL() - System.currentTimeMillis(), SLEEP_BOUND);
    while (waitTime > 0L) {
      long startSleep = System.currentTimeMillis();
      Thread.sleep(waitTime);
      waitTime -= (System.currentTimeMillis() - startSleep);
    }

    task.lock();
    try {
      // If this task is already in an end state, it means that the resource releasing will be
      // handled by other threads, we don't care anymore.
      if (task.isEndState()) {
        return;
      }
      // if the Task still has not reached the time limit, re-push the task in the TimeoutQueue.
      if (task.getDDL() - System.currentTimeMillis() > 0L) {
        scheduler.enforceTimeLimit(task);
        return;
      }
    } finally {
      task.unlock();
    }
    LOGGER.warn(
        "[DriverTaskTimeout] Current time is {}, ddl of task is {}",
        System.currentTimeMillis(),
        task.getDDL());
    task.setAbortCause(new QueryTimeoutException());
    scheduler.toAborted(task);
  }
the thread for watching the timeout of {@link DriverTask}.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/schedule/DriverTaskTimeoutSentinelThread.java