Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Main thread terminates when main method exits

 
Jeganathan Swaminathan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Randall Twede
Ranch Hand
Posts: 4371
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Randall Twede
Ranch Hand
Posts: 4371
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic