This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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?
SCJP - 86% - June 11, 2009
Joined: Mar 22, 2005
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.