FileDocCategorySizeDatePackage
ShutDownHook.javaAPI DocExample2879Sun Feb 08 21:34:08 GMT 2004None

ShutDownHook

public class ShutDownHook extends Object
Demonstrate adding a Shutdown Hook to the Runtime.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		System.err.println("Starting main program");
		Runtime rt = Runtime.getRuntime();
		System.err.println("Main: adding shutdown hook");
		rt.addShutdownHook(new Thread() {
			public void run() {
				// In real life this might close a Connection or something.
				System.err.println("Running my shutdown hook");
			}
		});
		System.err.println("Main: calling Runtime.exit()");
		rt.exit(0);