This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Is the answer right about this question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Is the answer right about this question?" Watch "Is the answer right about this question?" New topic
Author

Is the answer right about this question?

david hu
Ranch Hand

Joined: Jul 20, 2001
Posts: 143
Answer for the following question is a.b.c.e
But I think e is not right. 'cause one thread can stop buy invoke the sleep method of another object( and this object refered to another thread).
From(http://www.javaranch.com/maha/_Mock_Exams/MindQ_s_Sun_Certified_Java_Programmer_Practice_Test.htm Question41)
---
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.
Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1242
Originally posted by david hu:
Answer for the following question is a.b.c.e
But I think e is not right. 'cause one thread can stop buy invoke the sleep method of another object( and this object refered to another thread).
From(http://www.javaranch.com/maha/_Mock_Exams/MindQ_s_Sun_Certified_Java_Programmer_Practice_Test.htm Question41)
---
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.

Huh?? "and this object refered to another thread"
"e) The thread's sleep() method was invoked. " says that? I dont think it refers to another thread. For example, mythreadobject pass to another anotherthreadobject so call mythreadobject.sleep() in this method cause the thread to sleep?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
Note that sleep is a static method of the Thread class. It is always the Thread that calls sleep that goes to sleep. How could it be any other way?
Also yield is a static method.
All objects have a wait method by virtue of inheritance from Object, however, a Thread calling its own wait method is useless. When wait is used in a program, it is the wait method of a particular object.
Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1242
oops.. forgot about that, static. sorry!
 
Consider Paul's rocket mass heater.
 
subject: Is the answer right about this question?
 
Similar Threads
Threads MindQ 41
Thread execution
MindQ question #41
Garbage collection
Thread question form MindQ