first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

Java Practices: “Use System.exit with care”; javapractices.com

System.exit should be used with care. The normal method of terminating a program is to terminate all user threads.

Cases in which System.exit is appropriate :

* utility scripts
* GUI applications, in which the event dispatch user thread is created in the background. 

Here, the program may be terminated by calling System.exit, or, for example, by setting JFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE).

From Sun’s Portability Cookbook :

“The System.exit method forces termination of all threads in the Java virtual machine. This is drastic....System.exit should be reserved for a catastrophic error exit, or for cases when a program is intended for use as a utility in a command script that may depend on the program's exit code.”

[http://www.javapractices.com/topic/TopicAction.do?Id=86]

mod date: 2008-12-02T20:34:39.000Z