I have a question in this program.
public class TwoThread extends
Thread {
public void run()
{
for(int i=0;i<10;i++)
printMsg();
}
public void printMsg()
{
Thread t=Thread.currentThread();
String name=t.getName();
System.out.println("name:"+name);
}
public static void main(String args[])
{
TwoThred tt=new TwoThread();
tt.setName("Child Thread");
tt.start();
for(int i=0;i<10;i++)
tt.printMsg();
}
}
when tt.printMsg() from main is executed the main htread is being displayed. Why is this so.... why is not the child thread being displayed since thread ojext tt creates a new thread.