according to thread.yield(). the current working
thread is stopped and the other thread is started which is ready to run state.( Please tell me whether this is right or wrong..)
now this program.....
class worker implements Runnable
{
private Thread theThread;
public void kickStart()
{
if(theThread==null)
{
theThread=new Thread(this);
theThread.start();
}
}
public void terminate()
{
theThread=null;
}
public void run()
{
while(theThread==Thread.currentThread())
{
System.out.println("going ard in loops");
}
}
}
public class controller
{
public static void main(
String args[])
{
worker w=new worker();
w.kickStart();
Thread.yield();
w.terminate();
}
}
the output varies every time we run this program can u tell how this happens..........