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 !!
Leverager of our synergies
Joined: Aug 26, 2000
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�