This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android 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 Communication - Starting and Stopping the threads
Thread.activeCount()
Six java questions: Could anyone answer
status of deamon threads
Evidence 4 Main Thread dead after main method exits