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 Difference Between Include Directive and Include Action o ...

What is the Reason to Organize Classes and Interfaces in a Packag ...

What is the Difference Between wait and sleep Methods in Java ?

When is UnsupportedOperationException Thrown in Java ?

What is the Difference Between StringBuffer and StringBuilder in ...