1.

What is a shutdown hook?

Answer»

A shutdown hook is simply a thread that is invoked implicitly before JVM shuts down. It is one of the most important FEATURES of JVM because it provides the capacity to do RESOURCE cleanup or SAVE APPLICATION state JVM shuts down.  By calling the halt(INT) method of the Runtime class, the shutdown hook can be stopped. Using the following method, one can add a shutdown hook. 

public void addShutdownHook(Thread hook){} Runtime r=Runtime.getRuntime(); r.addShutdownHook(new MyThread());


Discussion

No Comment Found