

They should also not rely blindly upon services that may Particular, be written to be thread-safe and to avoid deadlocks insofarĪs possible. Machine and should therefore be coded defensively. Shutdown hooks run at a delicate time in the life cycle of a virtual 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

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,
#Deskgram java runtime code#
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
