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

Does Java Allow Virtual Functions ?

How Will You Handle InterruptedException in Java ?

What is the Lifecycle Stages of JSP ?

What are the Differences Between Comparable and Comparator in Jav ...

Why Do We Use JSP Instead of Servlet in Java ?