Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marcus

 
Vivek Shrivastava
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vivek:
I agree with u.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic