public class AppShutdownHook extends Thread{ public void run(){ logger.info("Running shutdown hook...") ; //cleanup e.g. close database connections } }2. Register the shutdown hook:
public class App{ public App(){ Runtime.getRuntime(). addShutdownHook(new AppShutdownHook()) ; } }Note that no guarantee can be made about whether or not any shutdown hooks will be run if the JVM aborts with the SIGKILL signal (kill -9) on Unix or the TerminateProcess call on MS Windows.However, SIGTERM (kill with no arguments) will work.Reference:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)
Really very good blog for wow gold its really excellent. The content of your
ReplyDeleteblog Is really superb.