public void addShutdownHook(Thread hook){
  SecurityManager sm=System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(RuntimePermissionCollection.SHUTDOWN_HOOKS_PERMISSION);
  }
  if (hook == null)   throw new NullPointerException("null is not allowed here");
  if (hook.getState() != Thread.State.NEW) {
    throw new IllegalArgumentException();
  }
  if (VMState > 0) {
    throw new IllegalStateException();
  }
synchronized (hooksList) {
    if (hooksList.contains(hook)) {
      throw new IllegalArgumentException();
    }
    hooksList.add(hook);
  }
}

public void addShutdownHook ( Thread hook ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( RuntimePermissionCollection . SHUTDOWN_HOOKS_PERMISSION ) ; } if ( hook == null ) throw new NullPointerException ( "null is not allowed here" ) ; if ( hook . getState ( ) != Thread . State . NEW ) { throw new IllegalArgumentException ( ) ; } if ( VMState > 0 ) { throw new IllegalStateException ( ) ; } synchronized ( hooksList ) { if ( hooksList . contains ( hook ) ) { throw new IllegalArgumentException ( ) ; } hooksList . add ( hook ) ; } }
registers a new virtual - machine shutdown hook .
