What is a Shutdown Hook in Java ?

The shutdown hook is a thread that is invoked implicitly by JVM just before the shut down. It can be used to clean up unused resources etc.

We can use java.lang.Runtime.addShutdownHook(Thread hook) method to register a new virtual-machine shutdown hook.



You May Interest

What is the Difference Between Expression and Scriptlet in JSP ?

What are the Different Types of Classloaders in Java ?

Java How To Find The Average Of 10 Numbers Using A While Loop

What is a Livelock in Java ?

How Will You Delete a Cookie in JSP ?