Catching Ctrl+C in Java
You can attach a shutdown hook to the VM which gets run whenever the VM shuts down: The Java virtual machine shuts down in response to two kinds of events: The program exits normally, when the last non-daemon thread exits or when the exit (equivalently, System.exit) method is invoked, or The virtual machine is terminated … Read more