This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Daemon Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Daemon Threads" Watch "Daemon Threads" New topic
Author

Daemon Threads

Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
Hi all,
Just to clear something up. What are daemon threads?
If you have created a Thread and you call setDaemon() on it. What exactly are you doing to the thread?
Thx
Brian
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

Daemon threads die when the thread that created them dies. non-daemon threads do not. If a thread is a daemon, then any threads it creates will automatically be daemons.

SCJP
Visit my download page
Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
Thanks for clearing that up for me Randall
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
"Daemon threads die when the thread that created them dies. non-daemon threads do not."
NO NO NO NO NO
A Java program quits when the only Threads left are Daemon threads. (ie all user Threads have died) Thats because Daemon Threads carry on all of the JVM's background activities. There IS NO parent-child relationship among Threads. A Thread only has a ThreadGroup - not a parent.
Bill


------------------
author of:
Brian, Cavanagh
Ranch Hand

Joined: Oct 30, 2000
Posts: 70
Ok,
Thanks Bill. BTW, did your 70 q's last Fri. good exam... some tricky questions on it.
Once again,
Cheers
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

thanks bill. i know my second statement was right. thanks for clearing up the first part.
 
Consider Paul's rocket mass heater.
 
subject: Daemon Threads