private static void startMetaStoreThreads(final Configuration conf, final Lock startLock,
      final Condition startCondition, final AtomicBoolean startedServing,
      final AtomicBoolean startedBackGroundThreads) {
    // A thread is spun up to start these other threads.  That's because we can't start them
    // until after the TServer has started, but once TServer.serve is called we aren't given back
    // control.
    Thread t = new Thread() {
      @Override
      public void run() {
        // This is a massive hack.  The compactor threads have to access packages in ql (such as
        // AcidInputFormat).  ql depends on metastore so we can't directly access those.  To deal
        // with this the compactor thread classes have been put in ql and they are instantiated here
        // dyanmically.  This is not ideal but it avoids a massive refactoring of Hive packages.
        //
        // Wrap the start of the threads in a catch Throwable loop so that any failures
        // don't doom the rest of the metastore.
        startLock.lock();
        try {
          JvmPauseMonitor pauseMonitor = new JvmPauseMonitor(conf);
          pauseMonitor.start();
        } catch (Throwable t) {
          LOG.warn("Could not initiate the JvmPauseMonitor thread." + " GCs and Pauses may not be " +
              "warned upon.", t);
        }

        try {
          // Per the javadocs on Condition, do not depend on the condition alone as a start gate
          // since spurious wake ups are possible.
          while (!startedServing.get()) {
            startCondition.await();
          }

         LeaderElectionContext context = new LeaderElectionContext.ContextBuilder(conf)
             .setHMSHandler(thriftServer.getHandler()).servHost(getServerHostName())
             .setTType(LeaderElectionContext.TTYPE.ALWAYS_TASKS) // always tasks
             .addListener(new HouseKeepingTasks(conf, false))
             .setTType(LeaderElectionContext.TTYPE.HOUSEKEEPING) // housekeeping tasks
             .addListener(new CMClearer(conf))
             .addListener(new StatsUpdaterTask(conf))
             .addListener(new CompactorTasks(conf, false))
             .addListener(new CompactorPMF())
             .addListener(new HouseKeepingTasks(conf, true))
             .setTType(LeaderElectionContext.TTYPE.WORKER) // compactor worker
             .addListener(new CompactorTasks(conf, true),
                 MetastoreConf.getVar(conf, MetastoreConf.ConfVars.HIVE_METASTORE_RUNWORKER_IN).equals("metastore"))
             .build();
          if (shutdownHookMgr != null) {
            shutdownHookMgr.addShutdownHook(() -> context.close(), 0);
          }
          context.start();
        } catch (Throwable e) {
          LOG.error("Failure when starting the leader tasks, Compaction or Housekeeping tasks may not happen", e);
        } finally {
          startLock.unlock();
        }

        if (startedBackGroundThreads != null) {
          startedBackGroundThreads.set(true);
        }
      }
    };
    t.setDaemon(true);
    t.setName("Metastore threads starter thread");
    t.start();
  }
Start threads outside of the thrift service, such as the compactor threads.
@param conf Hive configuration object
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java