wood burning stoves 2.0*
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Daemon Threads