private static void addShutdownHook(Runnable shutdownHook, int priority, long timeout) {
    if (priority < 0 || priority > GRACEFUL_SHUTDOWN_HOOK_PRIORITY) {
      throw new IllegalArgumentException("Priority should be ranged between 0 and " +
          GRACEFUL_SHUTDOWN_HOOK_PRIORITY);
    }
    if (!isShutdownInProgress()) {
      MGR.addShutdownHook(shutdownHook, priority, timeout, TimeUnit.SECONDS);
    }
  }
Adds a shutdownHook with a priority, the higher the priority
the earlier will run. ShutdownHooks with same priority run
in a non-deterministic order.

@param shutdownHook shutdownHook <code>Runnable</code>
@param priority priority of the shutdownHook.
@param timeout timeout of the shutdownHook.
common/src/java/org/apache/hive/common/util/ShutdownHookManager.java