private void runWmThread() {
    while (true) {
      EventState currentEvents = null;
      currentLock.lock();
      try {
        while (!hasChanges) {
          try {
            hasChangesCondition.await(1, TimeUnit.SECONDS);
          } catch (InterruptedException e) {
            LOG.warn("WM thread was interrupted and will now exit");
            return;
          }
        }
        hasChanges = false;
        currentEvents = current;
        current = (currentEvents == one) ? two : one;
      } finally {
        currentLock.unlock();
      }
      try {
        LOG.info("Processing current events");
        processCurrentEvents(currentEvents, syncWork);
        scheduleWork(syncWork);
        updateSessionTriggerProvidersOnMasterThread();
      } catch (InterruptedException ex) {
        LOG.warn("WM thread was interrupted and will now exit");
        return;
      } catch (Exception | AssertionError ex) {
        LOG.error("WM thread encountered an error but will attempt to continue", ex);
        for (SettableFuture<Boolean> testEvent : currentEvents.testEvents) {
          LOG.info("Failing test event " + System.identityHashCode(testEvent));
          testEvent.setException(ex);
        }
        currentEvents.testEvents.clear();
        if (currentEvents.applyRpFuture != null) {
          currentEvents.applyRpFuture.setException(ex);
          currentEvents.applyRpFuture = null;
        }
        // TODO: we either have to kill HS2 or, as the non-actor model would implicitly,
        //       hope for the best and continue on other threads. Do the latter for now.
        continue;
      }
    }
  }
The work delegated from the master thread that doesn't have an async implementation
(mostly opening and closing the sessions).
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/WorkloadManager.java