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

Can We Use Thread.sleep Method For Real-time Processing in Java ?

What is the Difference Between an ArrayList and a LinkedList Data ...

What is the Difference Between Abstract Class and Interface in Ja ...

What is the Main Benefit of IOC Principle in Java ?

How Will You Use a Cookie in JSP ?