code: public void addMaybeStartHandler(Handler handler, Stage stage) throws Exception
    {
      if (!startStopLock.tryLock()) {
        // (*) This check is why the state should be changed before startStopLock.lock() in stop(). This check allows to
        // spot wrong use of Lifecycle instead of entering deadlock, like https://github.com/apache/incubator-druid/issues/3579.
        if (state.get().equals(State.STOP)) {
          throw new ISE("Cannot add a handler in the process of Lifecycle stopping");
        }
        startStopLock.lock();
      }
      try {
        if (state.get().equals(State.STOP)) {
          throw new ISE("Cannot add a handler after the Lifecycle has stopped");
        }
        if (state.get().equals(State.RUNNING)) {
          if (stage.compareTo(currStage) <= 0) {
            handler.start();
          }
        }
        handlers.get(stage).add(handler);
      }
      finally {
        startStopLock.unlock();
      }
    }
docs: Adds a handler to the Lifecycle and starts it if the lifecycle has already been started.
  
  @param handler The hander to add to the lifecycle
  @param stage   The stage to add the lifecycle at
  
  @throws Exception an exception thrown from handler.start().  If an exception is thrown, the handler is *not* added