public class Rpcraven
{
public static void main(
String argv[]){
Pmcraven pm1 = new Pmcraven("one");
pm1.start();
System.out.println("what the hell are u doing");
Pmcraven pm2 = new Pmcraven("two");
pm2.start();
}
}
class Pmcraven extends
Thread {
private String sTname="";
Pmcraven(String s)
{
sTname = s;
}
public void run()
{
for(int i =0; i<5 ; i++){
try
{
sleep(1000);
}
catch(InterruptedException e)
{
}
yield();
System.out.println(sTname);
}
}
}
In the above given code,i have created two thread's named one and two.My question is when the thread "one" yields for the first time,second thread named "two" should start running immediately.Initial two line's of output should be "two","one" not "one","two".Please throw some light on it.