/ Published in: Java
to shutdown a program with ctrl-c
Expand |
Embed | Plain Text
public class MonExample { protected boolean isRunning = false; [...] // Setup a hook to clean the resources when the CTRL-C key is stroken initOtherClasses(); isRunning = true; } [...] shutdownOtherClasses(); isRunning = false; } [...] // This class is an helper class to manage the CTRL-C stop of the // application protected MonExample monExample = null; public ResourcesCleanerMonExample monExample { monExample = monExample } public void run() { try { if(isRunning) monExample.shutdown(); STLogger.error("MonExample", "Error while shutting down MonExample", e); } } } }
Comments
Subscribe to comments
You need to login to post a comment.

to shutdown a program with ctrl-c