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

How HashMap Works in Java ?

What are the Different Types of Classloaders in Java ?

How Can We Prevent Busy Waiting in Java ?

What are the Atomic Operations in Java ?

Why ListIterator Has add Method But Iterator Does Not Have in Jav ...