< prev index next >

src/java.base/share/classes/java/lang/Shutdown.java

Print this page




 119         }
 120 
 121         for (int i=0; i < MAX_SYSTEM_HOOKS; i++) {
 122             try {
 123                 Runnable hook;
 124                 synchronized (lock) {
 125                     // acquire the lock to make sure the hook registered during
 126                     // shutdown is visible here.
 127                     currentRunningHook = i;
 128                     hook = hooks[i];
 129                 }
 130                 if (hook != null) hook.run();
 131             } catch (Throwable t) {
 132                 if (t instanceof ThreadDeath) {
 133                     ThreadDeath td = (ThreadDeath)t;
 134                     throw td;
 135                 }
 136             }
 137         }
 138 




 139         // set shutdown state
 140         VM.shutdown();
 141     }
 142 
 143     /* Notify the VM that it's time to halt. */
 144     static native void beforeHalt();
 145 
 146     /* The halt method is synchronized on the halt lock
 147      * to avoid corruption of the delete-on-shutdown file list.
 148      * It invokes the true native halt method.
 149      */
 150     static void halt(int status) {
 151         synchronized (haltLock) {
 152             halt0(status);
 153         }
 154     }
 155 
 156     static native void halt0(int status);
 157 
 158     /* Invoked by Runtime.exit, which does all the security checks.




 119         }
 120 
 121         for (int i=0; i < MAX_SYSTEM_HOOKS; i++) {
 122             try {
 123                 Runnable hook;
 124                 synchronized (lock) {
 125                     // acquire the lock to make sure the hook registered during
 126                     // shutdown is visible here.
 127                     currentRunningHook = i;
 128                     hook = hooks[i];
 129                 }
 130                 if (hook != null) hook.run();
 131             } catch (Throwable t) {
 132                 if (t instanceof ThreadDeath) {
 133                     ThreadDeath td = (ThreadDeath)t;
 134                     throw td;
 135                 }
 136             }
 137         }
 138 
 139         // Notify the VM to link the classes loaded by the builtin class loaders
 140         // during dynamic CDS dump.
 141         VM.linkClassesForCDS();
 142 
 143         // set shutdown state
 144         VM.shutdown();
 145     }
 146 
 147     /* Notify the VM that it's time to halt. */
 148     static native void beforeHalt();
 149 
 150     /* The halt method is synchronized on the halt lock
 151      * to avoid corruption of the delete-on-shutdown file list.
 152      * It invokes the true native halt method.
 153      */
 154     static void halt(int status) {
 155         synchronized (haltLock) {
 156             halt0(status);
 157         }
 158     }
 159 
 160     static native void halt0(int status);
 161 
 162     /* Invoked by Runtime.exit, which does all the security checks.


< prev index next >