Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Daemon Threads

 
Brian, Cavanagh
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4371
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Brian, Cavanagh
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for clearing that up for me Randall
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4371
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks bill. i know my second statement was right. thanks for clearing up the first part.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic