File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes What is a daemon thread? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "What is a daemon thread?" Watch "What is a daemon thread?" New topic

What is a daemon thread?

Sudipto Ghosh

Joined: Jan 07, 2005
Posts: 11
What is a daemon thread? When should I use setDaemon() and why?
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: What is a daemon thread?
It's not a secret anymore!