
#GETAMPED2 JAVA RUNTIME CODE#
Status code will override the status code passed to that method. If the exit (equivalently, System.exit) method has already been invoked then this Shutdown hooks or finalizers to finish their work. If the shutdown sequence hasĪlready been initiated then this method does not wait for any running Hooks to be started and does not run uninvoked finalizers ifįinalization-on-exit has been enabled. Unlike theĮxit method, this method does not cause shutdown This method should be used with extreme caution.

New shutdown hook or de-register a previously-registered hook.Īttempting either of these operations will cause an Once the shutdown sequence has begun it is impossible to register a Once the shutdown sequence has begun it can be stopped only by If shutdown was initiated by invoking the exit Note that daemon threads willĬontinue to run during the shutdown sequence, as will non-daemon threads Run all uninvoked finalizers if finalization-on-exit has been enabled.įinally, the virtual machine will halt. When all the hooks have finished it will then Start all registered shutdown hooks in some unspecified order and let When the virtual machine begins its shutdown sequence it will User interrupt, such as typing ^C, or a system-wide event,Ī shutdown hook is simply an initialized but unstarted The virtual machine is terminated in response to a.Thread exits or when the exit (equivalently, The program exits normally, when the last non-daemon.The Java virtual machine shuts down in response to two kinds Registers a new virtual-machine shutdown hook. addShutdownHook public void addShutdownHook( Thread hook).Throws: SecurityException - If a security manager is present and its checkExit method does not permitĮxiting with the specified status See Also: SecurityException, With the given status code if the status is nonzero otherwise, itĬonventional and convenient means of invoking this method. If shutdown hooks have already been run and on-exitįinalization has been enabled then this method halts the virtual machine Shutdown sequence then if shutdown hooks are being run this method willīlock indefinitely. If this method is invoked after the virtual machine has begun its Once this is done the virtual machine halts. In the second phase all uninvokedįinalizers are run if finalization-on-exit If any, are started in some unspecified order and allowed to runĬoncurrently until they finish. The first phase all registered shutdown hooks,

The virtual machine's shutdown sequence consists of two phases. Serves as a status code by convention, a nonzero status code indicates Terminates the currently running Java virtual machine by initiating its
