This week's giveaway is in the Spring forum.
We're giving away four 3 month subscriptions to Marco Behler Videos and have Marco Behler on-line!
See this thread for details.
Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is a daemon thread?  RSS feed

 
Sudipto Ghosh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a daemon thread? When should I use setDaemon() and why?
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of what you would want to know is in the API for java.lang.Thread and it's a shame that you don't read them.

A good example of an application of a daemon thread would be some type of background clean-up operation. If clean-up is only operating on the Java heap, then there is no need to delay JVM shut-down while a clean-up operation completes. If you put the clean-up operation in a Daemon thread, it won't delay shut-down.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter is right - learn to love the JavaDoc! He also gave a much nicer explanation than the JavaDoc which has some legalese double-negative convoluted wording about daemon. I always have to read it about 5 times to parse it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!