This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Under what circumstances will a thread stop? Select all valid answers. (a) The method waitForID() in the class MediaTracker is called. (b) The run() method that the thread is executing ends. (c) The call to the start() method of the Thread object returns. (d) The suspend() method is called on the Thread object. (e) The wait() method is called on the Thread object. The answer given is: b But I think the answers should be a,b,d,e should all be correct. I guess the confusion here is with the word "stop" and "block". Can anyone comment on this? Also what about MediaTracker...will it block a thread from running? Please reply as I'm taking the exam tomorrow
Following are my views. please correct me if i am wrong. I think when the question says "stop", it means never having a chance to run again. (a) The method waitForID() in the class MediaTracker is called. The thread blocks and goes to "Wait" state. it does not stop. (b) The run() method that the thread is executing ends. The Thread stops (c) The call to the start() method of the Thread object returns. The thread does not stop in this case. very obvious. (d) The suspend() method is called on the Thread object. The thread goes to a "wait" state and might become "Ready" again when the resume() (deprecated) method is called. (e) The wait() method is called on the Thread object. The thread goes to a wait state. Might run again.
Hi Now it is time to clear all the doubts. i am going to take exam very soon. what does the exact meaning of "stop" word in context of thread ? Because in the link provided by "ajith" in this thread he is taking "stop" as temporally stop of thread and thread may be runnable after some time. In case of khalid exam he is taking "stop" as permanent "stop" of thread. (because Answer given for the question is �b�) please help me to clear my confusion. vivek
Junaid, I am sure your concepts about Threads are clear. You are not sure about this answer only because you are not sure what Khalid really means by 'stop'. I doubt if 'Sun' will have any such questions where you have to wonder what the question really is. So don't panic. All the best in your exam tomorrow.