public void addShutdownHook(Runnable shutdownHook,int priority){
  if (shutdownHook == null)   throw new IllegalArgumentException("shutdownHook cannot be NULL");
  hooks.add(shutdownHook);
}

public void addShutdownHook ( Runnable shutdownHook , int priority ) { if ( shutdownHook == null ) throw new IllegalArgumentException ( "shutdownHook cannot be NULL" ) ; hooks . add ( shutdownHook ) ; }
adds a shutdownhook with a priority , the higher the priority the earlier will run . shutdownhooks with same priority run in a non - deterministic order .
