Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread question form MindQ

 
Chun Wang
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
41. For what reasons might a thread stop execution?
a) A thread with higher priority began execution.
b) The thread's wait() method was invoked.
c) The thread invoked its yield() method.
d) The thread's pause() method was invoked.
e) The thread's sleep() method was invoked.
my answer is b,c,d,e. I don't know what the correct answer is but it tells me I was wrong. could anyone help tell me what is correct and explain? thanks a bunch.
chun
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The key here is that it says "MIGHT" stop a thread.
A. True — Some systems will stop threads of lower priority to start threads of higher priority, some don't but again, this might be true.
B. True — wait() will put the thread into waiting state, so it does stop it.
C. True — yield() will cause a thread to stop for higher priority threads. So it does cause it to stop.
D. False — There is no pause method.
E. True — sleep() will cause a thread to stop for a given amount of time.
Bill
 
deepak1
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi
I am not satisfied with the second option .
"The thread's wait() method was invoked."
since wait() method is defined in the object class.So how can a thread's wait() method can be invoked. What i meant that the statement should be like that ..
"The wait() method is called."
thanks
deepak
 
Haining Mu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not satisfied with the second option .
"The thread's wait() method was invoked."
since wait() method is defined in the object class.So how can a thread's wait() method can be invoked. What i meant that the statement should be like that ..
"The wait() method is called."

Thread class inherit wait() from Object, so I think it is now his method.
And I think answer e) is wrong since no sleep() method in Thread class which does not take a parameter.
 
Jyotsna Umesh
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Haining Mu:
Thread class inherit wait() from Object, so I think it is now his method.
And I think answer e) is wrong since no sleep() method in Thread class which does not take a parameter.

Hi everybody,
I agree with Bill, he has explained well and i see option e is right becoz for exam's purpose you will have to make certain assumptions. Right!
Jyotsna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic