code: public synchronized void waitForLevel() {
          while (!levelReached) {
              if (hookSet == false) {
                  Runtime.getRuntime().addShutdownHook(shutdownHook);
                  hookSet = true;
              }
  
              try {
                  wait();
              } catch (InterruptedException e) {
                  /** No-op **/
              }
          }
      }
docs: Attach a shutdown hook to make sure that the thread waiting for the start
  level to change is posted if the JVM is shut down