[JAVA] Runtime.getRuntime().addShutdownHook

Before jvm finishs, it will run the thread added to Runtime.getRuntime().addShutdownHook

good for watch dog

public void attachWatchDog() {
   Runtime.getRuntime().addShutdownHook(new Thread() {
      public void run() {
         System.out.println("your last chance before program terminated");
Tags :

0 thoughts on “[JAVA] Runtime.getRuntime().addShutdownHook”

Leave a Reply

Your email address will not be published. Required fields are marked *

× 1 = one

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>