Hi!, I have this question. When does the JVM exit. 1)After the main method returns. 2)After all the non demons threads created by the application complete. 3)After all the demon threads created by the application complete. 4)When a thread executes System.exit(). 5)When an uncaught exception is thrown in a non demon thread. 6)When an uncaught exception is thrown in a demon thread.
SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
posted
0
1)After the main method returns. The JVM exits if there are no non-daemon threads running. 2)After all the non demons threads created by the application complete. Always. 3)After all the demon threads created by the application complete. Doesn't matter. The JVM will exit before they complete if all the non-daemon threads complete first. 4)When a thread executes System.exit(). Maybe. A SecurityException could be thrown or the method could block indefinitely under certain cirucmstances. Take a look at the API docs on System.exit and Runtime.exit. 5)When an uncaught exception is thrown in a non demon thread. If the exception propagates past its run method and it is the only running non-daemon thread.
6)When an uncaught exception is thrown in a demon thread. Nope. [ February 15, 2004: Message edited by: Michael Morris ]
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.