Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes exit of JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "exit of JVM" Watch "exit of JVM" New topic

exit of JVM

Ranch Hand

Joined: Jul 20, 2000
Posts: 112
Hi All,

Does JVM exits after the main() thread ?
I think it does - True.
But I found that one of the mock test says that some other threads may still be running.
How is this possible ? Can anyone explain.
Your help is appreciated.
Thx in Advance.
Mapraputa Is
Leverager of our synergies

Joined: Aug 26, 2000
Posts: 10065
Does JVM exits after the main() thread?
1) if main() method (main thread) did not start other thread, JVM exits
2) if other (non-daemon) thread was constructed in main() method, and this new thread is still running, JVM will wait until it finishes.
2) if main() method ended and there are only daemon threads running, JVM exits.

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
I agree. Here's the link:
subject: exit of JVM
It's not a secret anymore!