permaculture playing cards*
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
Don't get me started about those stupid light bulbs.
 
subject: Marcus
 
Similar Threads
Marcus Green's Exam 3 #44 - yield()
Marcus Green Mock 3 Q49
Marcus Green #3, Q44
Marcus Mock Exam 3- Q44
yield();