Re: Best way to halt Java process?
On 6/10/2010 12:02 PM, Todd wrote:
On Jun 10, 9:06 am, Alessio Stalla<alessiosta...@gmail.com> wrote:
Just keep in mind that System.exit kills the entire JVM, so if your
"process" is a webapp in a servlet container, you'll kill all the
other webapps and the container, too.
That's what I understood, but thanks for the reminder. For the
purposes of this process/application, failing to a safe-mode (in this
case where no further processing is allowed) is best, so halting the
JVM is reasonable.
Keep in mind that things like application servers and browsers
will not allow applets/servlets/whatnot to stop the JVM: They'll
install security managers, and System.exit() will wind up throwing
SecurityException. Assuming you don't catch it, this will cause the
thread that called System.exit() to terminate. But if you've launched
additional threads, they won't be affected by the intercepted attempt
to exit. Not necessarily a problem (especially in your case, where
I gather the problem is detected early and you might not have launched
a lot of threads yet), but something to be aware of.
--
Eric Sosman
esosman@ieee-dot-org.invalid