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 Thread Starvation in Java ?

What is the Main Difference Between a Session and Cookie in JSP ?

Why Should You Define a Default Constructor in Java ?

What are the Similarities Between HashSet and HashMap in Java ?

How Does hashCode Method Work in Java ?