Runtime.getRuntime().addShutdownHook(Thread); Before JVM shut down, it will call each hook you added.