This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Threads" Watch "Threads" New topic
Author

Threads

Nandini Gangopadhyay
Ranch Hand

Joined: Apr 02, 2001
Posts: 79
Hi all,
I have a question, hopefully someone will help me......what happens to any thread which has been started in the main method when the main method exits? Does the thread terminate by itself? I think it should terminate.....Please help!
Nandini
nitin sharma
Ranch Hand

Joined: Feb 24, 2001
Posts: 290
hi,
if the thread is a user thread then it keep's on running even if the main thread die.
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 2912
There is no affect of the thread running the main() method on the threads created by main() method. Other threads keep on running as per how they are programmed even if the main thread dies.
The whole program ends only when all the non-daemon threads end.
Simple analogy, children don't die when the parents die. Do you think they should?
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

Try out the world's only WebCompiler!
www.jdiscuss.com


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 2912
Even daemon threads created by main won't die, if there are other non-daemon threads running.
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

Try out the world's only WebCompiler!
www.jdiscuss.com
Nandini Gangopadhyay
Ranch Hand

Joined: Apr 02, 2001
Posts: 79
Thanks guys, I got it!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads
 
Similar Threads
join
Thread signatures help please
main()
Main thread and child thread
line of exit program code?