Breaking News
Home / Java / Java Tutorials / Understanding Java Shutdown Hook

Understanding Java Shutdown Hook

JVM Shutdown Hook SnippetThe JVM provides the capability to add Shutdown hooks at Runtime. This shutdown hooks can be used to perform any resource cleanup or save state as required just before the JVM shuts down either normally or abruptly.

There can be more than one shutdown hooks that can be registered any time when the JVM is running via Runtime API. This hook is implemented as a Java Thread. The thread has the run() method which will get executed when the hook is executed by JVM at shutdown.

Java Shutdown Hook Example

The following example shows how to use the Java Shutdown Hook.


Check Also

Have a Question

How to select a JVM Analyzing Tool?

A JVM monitoring tool also know as a Diagnostic might be needed to fine tune …

Advertisment ad adsense adlogger