Yes Jeganathan main thread dies before the child thread in your case. I too had this confusion but after reading khalid I'm satisfied. Read page no. 273.
My doubt originated from the program that I tried. Here's it.
// program to demonstrate main thread dies before the child thread.
class ChildThread extends Thread
{
Thread mainThread;
ChildThread(Thread t)
{
mainThread = t;
}
public void run()
{
System.out.println("Main thread is alive at the start of run meth() : " + mainThread.isAlive());
try
{
for(int i =0;i<5;i++)
{
sleep(500);
System.out.println("Child Thread counting : " + i);
System.out.println("Main thread is alive in the run meth() : " + mainThread.isAlive());
}
} catch(InterruptedException r){}
System.out.println("Main thread is alive at the end of run meth() : " + mainThread.isAlive());
}
}
public class MainThreadIsAlive
{
public static void main(
String a[])
{
Thread t = Thread.currentThread();
System.out.println("Main thread is alive at the start of main meth() : " + t.isAlive());
ChildThread child = new ChildThread(t);
child.start();
System.out.println("Main thread is alive at the end of main meth() : " + t.isAlive());
}
}
-vadiraj