File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Java 8 in Action this week in the Java 8 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: 4339
    
    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: 4339
    
    2

i guess???
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Main thread terminates when main method exits
 
Similar Threads
Thread.activeCount()
Six java questions: Could anyone answer
Evidence 4 Main Thread dead after main method exits
status of deamon threads
Thread Communication - Starting and Stopping the threads