• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

does main thread die??

 
pitambari parekh
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does the main thread die??
If so, how???
please help me with..
Thanks..

Regards,
Pitambari.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not quite clear to me what you're asking - is it about a Java application, and by "main thread' you mean the one executing the "main" method?

If so, and if by "die" you mean whether the tread is terminated at the end of the method, then the answer is yes. That does not necessarily mean that the application terminates at that point, though. As long as other non-daemon threads are running (which is quite likely if it is a GUI application) then the application will continue to run.

Does that answer your question?
 
Bob Ruth
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf, this is not an attempt to hijack, just an attempt to clarify my perception of the question.....

I have seen cases where (mostly the book examples on spinning off threads...) the main method instantiates and starts up threads.... and then just falls to what would NORMALLY be the end of the program.

I am aware that, after starting the other thread(s) the main thread is still a viable thread and if you code something it will continue to execute....BUT...

if you dont continue code in the main thread, does the main thread just drop to some non-dispatchable state and wait on the rest of the threads to die, or does the whole process (and all threads started) die?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main thread does terminate (sounds less dramatic than "die", doesn't it ). But -as mentioned above- that does not mean that the JVM terminates, as long as other non-daemon threads are still around.
 
Bob Ruth
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I agree with the die/terminate issue!!!

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic