[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 *

4 × six =