Registering Shutdown Hooks for Virtual Machine : Runtime « Development Class « Java
- Java
- Development Class
- Runtime
Registering Shutdown Hooks for Virtual Machine
public class Main implements Runnable {
public void run() {
System.out.println("Shutting down");
}
public static void main(String[] arg) {
Runtime runTime = Runtime.getRuntime();
Main hook = new Main();
runTime.addShutdownHook(new Thread(hook));
}
}
Related examples in the same category