code: public static void addShutdownHook(final Thread shutdownHook) {
          Object token = ThreadIdentityManager.runAsServer();
          try {
              AccessController.doPrivileged( new PrivilegedAction<Void>() {
                  @Override
                  public Void run() {
                      Runtime.getRuntime().addShutdownHook(shutdownHook);
                      return null; // Nothing to return
                  }
              } );
          } finally {
              ThreadIdentityManager.reset(token);
          }
      }
docs: Add a shutdown hook as a privileged action.
  
  See {@link Runtime#addShutdownHook(Thread)}.
  
  @param shutdownHook The thread to add as a shutdown hook.