• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

When does the JVM exit

 
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic