Every Java Program can attach a shutdown hook to JVM, i.e. piece of instructions that JVM should execute before going down.
A program may require to execute some pieces of instructions when application goes down. An application may go down because of several reasons:
Because all of its threads have completed executionBecause of call to System.exit()Because user hit CNTRL-CSystem level shutdown or User Log-OffFew scenarios where this requirement fits are:
Saving application stat...
↧