O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Determine When Your Application Is About to Exit

What do you do when you want to shut down your Windows box? You click on Start. Likewise, when your application is shutting down, it doesn't stop at all. It rather starts something new. The application starts any registered shutdown threads. Only when they complete their work will the application exit. This is the case for normal termination—for instance, when you call this code:

System.exit(0);

Passing the 0 int to the exit method means, by convention, that everything is hunky dory in your application, and that you just want to end it. Typically, a non-zero number (such as -1), as you might imagine, indicates a non-normal termination.

Abnormal termination is typically unexpected, but there are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required