src/share/classes/java/lang/Runtime.java

Print this page




 100      * @see #removeShutdownHook
 101      * @see #runFinalizersOnExit
 102      * @see #halt(int)
 103      */
 104     public void exit(int status) {
 105         SecurityManager security = System.getSecurityManager();
 106         if (security != null) {
 107             security.checkExit(status);
 108         }
 109         Shutdown.exit(status);
 110     }
 111 
 112     /**
 113      * Registers a new virtual-machine shutdown hook.
 114      *
 115      * <p> The Java virtual machine <i>shuts down</i> in response to two kinds
 116      * of events:
 117      *
 118      *   <ul>
 119      *
 120      *   <p> <li> The program <i>exits</i> normally, when the last non-daemon
 121      *   thread exits or when the <tt>{@link #exit exit}</tt> (equivalently,
 122      *   <tt>{@link System#exit(int) System.exit}</tt>) method is invoked, or
 123      *
 124      *   <p> <li> The virtual machine is <i>terminated</i> in response to a
 125      *   user interrupt, such as typing <tt>^C</tt>, or a system-wide event,
 126      *   such as user logoff or system shutdown.
 127      *
 128      *   </ul>
 129      *
 130      * <p> A <i>shutdown hook</i> is simply an initialized but unstarted
 131      * thread.  When the virtual machine begins its shutdown sequence it will
 132      * start all registered shutdown hooks in some unspecified order and let
 133      * them run concurrently.  When all the hooks have finished it will then
 134      * run all uninvoked finalizers if finalization-on-exit has been enabled.
 135      * Finally, the virtual machine will halt.  Note that daemon threads will
 136      * continue to run during the shutdown sequence, as will non-daemon threads
 137      * if shutdown was initiated by invoking the <tt>{@link #exit exit}</tt>
 138      * method.
 139      *
 140      * <p> Once the shutdown sequence has begun it can be stopped only by
 141      * invoking the <tt>{@link #halt halt}</tt> method, which forcibly
 142      * terminates the virtual machine.
 143      *
 144      * <p> Once the shutdown sequence has begun it is impossible to register a




 100      * @see #removeShutdownHook
 101      * @see #runFinalizersOnExit
 102      * @see #halt(int)
 103      */
 104     public void exit(int status) {
 105         SecurityManager security = System.getSecurityManager();
 106         if (security != null) {
 107             security.checkExit(status);
 108         }
 109         Shutdown.exit(status);
 110     }
 111 
 112     /**
 113      * Registers a new virtual-machine shutdown hook.
 114      *
 115      * <p> The Java virtual machine <i>shuts down</i> in response to two kinds
 116      * of events:
 117      *
 118      *   <ul>
 119      *
 120      *   <li> The program <i>exits</i> normally, when the last non-daemon
 121      *   thread exits or when the <tt>{@link #exit exit}</tt> (equivalently,
 122      *   {@link System#exit(int) System.exit}) method is invoked, or
 123      *
 124      *   <li> The virtual machine is <i>terminated</i> in response to a
 125      *   user interrupt, such as typing <tt>^C</tt>, or a system-wide event,
 126      *   such as user logoff or system shutdown.
 127      *
 128      *   </ul>
 129      *
 130      * <p> A <i>shutdown hook</i> is simply an initialized but unstarted
 131      * thread.  When the virtual machine begins its shutdown sequence it will
 132      * start all registered shutdown hooks in some unspecified order and let
 133      * them run concurrently.  When all the hooks have finished it will then
 134      * run all uninvoked finalizers if finalization-on-exit has been enabled.
 135      * Finally, the virtual machine will halt.  Note that daemon threads will
 136      * continue to run during the shutdown sequence, as will non-daemon threads
 137      * if shutdown was initiated by invoking the <tt>{@link #exit exit}</tt>
 138      * method.
 139      *
 140      * <p> Once the shutdown sequence has begun it can be stopped only by
 141      * invoking the <tt>{@link #halt halt}</tt> method, which forcibly
 142      * terminates the virtual machine.
 143      *
 144      * <p> Once the shutdown sequence has begun it is impossible to register a