![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e50. Determining When the Application Is About to ExitWhen an application is terminated normally, the application first starts any registered shutdown threads, waits for them to complete and then finally exits. Normal termination can be caused by a call toSystem.exit() , the completion of the last non-daemon thread, or the
interruption of the application (control-C) by the user. Abnormal
termination (which does not cause the shutdown threads to be started)
is caused some major fault in the Java virtual machine or native
library.
// Register a shutdown thread Runtime.getRuntime().addShutdownHook(new Thread() { // This method is called during shutdown public void run() { // Do shutdown work ... } });
e49. Terminating the Application e51. Computing Elapsed Time e52. Loading Native Code e53. Implementing a Class That Can Be Sorted e54. Redirecting Standard Output, and Error e55. Getting the Size of the Heap
© 2002 Addison-Wesley. |