• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Khalid mock exam question (pls help urgent)

 
Junaid Bhatra
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exact same question has been discussed in detail here
Good luck for your exams
Ajith
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vivek Shrivastava
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sandra Marti
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic