private void runRestartThread() {
    try {
      while (true) {
        TezSessionPoolSession next = restartQueue.take();
        LOG.info("Restarting the expired session [" + next + "]");
        try {
          sessionRestartImpl.closeAndReopenExpiredSession(next);
        } catch (InterruptedException ie) {
          throw ie;
        } catch (Exception e) {
          LOG.error("Failed to close or restart a session, ignoring", e);
        }
      }
    } catch (InterruptedException e) {
      LOG.info("Restart thread is exiting due to an interruption");
    }
  }
Logic for the thread that restarts the sessions expired during foreground operations.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/SessionExpirationTracker.java