Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is the answer right about this question?

 
david hu
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1244
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1244
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops.. forgot about that, static. sorry!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic