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