File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Threads and JVM

 
Prasad Subramanian
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
I have a few doubts :
when does the JVM exit ?
a) when all the non -daemon threads are dead ?
b) when all threads incl. daemon are dead ?

What happens to the threads when the executing program terminates ?
I guess the non daemon threads terminate , but what abt non daemon ?
What does one mean by "stopping a thread "
does it imply :
stop "running " and get inyo waiting /sleeping
or "stop" altogether itself !!
Pls help !!
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. when does the JVM exit ?
a) when all the non -daemon threads are dead ?
b) when all threads incl. daemon are dead ?
Choice a is right
JVM exits when there are only daemon threads running
2. What does one mean by "stopping a thread "
you are right, this expression has two meanings:
1) moving a thread from running to blocked/waiting state
2) moving it from running to dead state.
My personal approach to this questions is: if choices given include �stop� method or System.exit(0), in other words, if there are choices for �killing� a thread, then the author probably has meaning #2 in mind. Otherwise, I assume meaning #1.
I hope on real exam we will not have so badly worded questions. Actually many people said there is no ambiguity on real exam.
BTW, here is a good diagram, showing all threads movements�
 
Prasad Subramanian
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot .
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic