---------------------------------------------------------------------
Output is
vandeleur
I am confused the above result. Could any one explain about the output?
----------------------------------------------------------------------
While a child
thread is started we cannot assure that always child thread execute immediately before main continues its code....
So makes little change.....
public class Tux extends Thread
{
static String sName = "vandeleur";
public static void main(String argv[]) throws InterruptedException
{
Tux t = new Tux();
t.piggy(sName);
System.out.println(sName);
}
public void piggy(String sName) throws InterruptedException
{
int i=10;
sName = sName + " wiggy";
start();
join(); //Added line
}
public void run()
{
for(int i=0;i < 4; i++)
{
sName = sName + " " + i;
}
}
}
and the desire output.............
vandeleur 0 1 2 3
i hope it clers U all