Determining When the Application Is About to Exit - Java Java Virtual Machine

Java examples for Java Virtual Machine:Utility

Description

Determining When the Application Is About to Exit

Demo Code

public class Main {

  public void m() {
    // Register a shutdown thread
    Runtime.getRuntime().addShutdownHook(new Thread() {
      // This method is called during shutdown
      public void run() {
        // Do shutdown work ...
      }//  w w w . ja va  2  s .  com
    });
  }
}

Related Tutorials