1: The Role
Trigger logic code that is executed before the end of the thread
Application stops sending alerts (email, SMS, message nails etc.); Close some connections
2: Use
// hooks
Runtime.getRuntime () addShutdownHook (. New new the Thread (() -> {
System.out.println ( "hooks: The End reminder" ); // do some tasks
}));