This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Main thread terminates when main method exits Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Main thread terminates when main method exits " Watch "Main thread terminates when main method exits " New topic
Author

Main thread terminates when main method exits

Jeganathan Swaminathan
Greenhorn

Joined: Dec 12, 2000
Posts: 5
I gone thru' the maha's discussion regarding thread. There it is clearly written that "MAIN THREAD IS ALIVE TILL ANY CHILD THREAD IS ALIVE" but from the program added below gives a different picture. So i expect some comments on this...


------------------
S.Jeganathan MCA
Software Engg.
PSI Data Systems Ltd.,
Bangalore.
jeganath@psi.soft.net


S.Jeganathan MCA<BR>Software Engg.<BR>PSI Data Systems Ltd.,<BR>Bangalore.<BR>jeganath@psi.soft.net
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

it is because you created a new thread at this line:
t1 = Thread.currentThread();
the method currentThread() returned a Thread which you assigned to t1. now t1 points at the same Thread the JVM is running(which is executing main at the moment).


SCJP
Visit my download page
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

i guess???
 
 
subject: Main thread terminates when main method exits
 
Similar Threads
Thread.activeCount()
Six java questions: Could anyone answer
Thread Communication - Starting and Stopping the threads
status of deamon threads
Evidence 4 Main Thread dead after main method exits