This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Marcus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Marcus" Watch "Marcus" New topic
Author

Marcus

Vivek Shrivastava
Ranch Hand

Joined: Jun 03, 2000
Posts: 277

Hi,
This question is from marcus exam.
Question 44)
Given a reference called
t
to to a class which extends Thread, which of the following will cause it to give up cycles to allow another thread to execute.
1) t.yield();
2) yield()
3) yield(100) //Or some other suitable amount in milliseconds
4) yield(t);

given answer is �2� but what is wrong with �1�. I have tried following example and it is working fine.
ublic class Test extends Thread{
static Test t;
public static void main(String arg[]){
t = new Test();
t.start();
}

public void run(){
System.out.println("before");
t.yield();
System.out.println("after");

}
}

please help me.
vivek
thomas
Ranch Hand

Joined: May 26, 2002
Posts: 79
Vivek:
I agree with u.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Yup. This was brought up some time ago in Mock Exam Errata, which is a good thing to search for stuff like this. Unfortunately it looks to me like Marcus never got around to updating this question, as the question is still the same as it was when the problem was first reported. Maybe we can attract his attention again this time.

"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Marcus