File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes what does daemon thread means? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what does daemon thread means?" Watch "what does daemon thread means?" New topic
Author

what does daemon thread means?

Jenny raj
Ranch Hand

Joined: May 19, 2005
Posts: 57
can anyone plz explain
thank u.
Robert Watkins
Greenhorn

Joined: Sep 20, 2005
Posts: 25
Originally posted by Jenny raj:
can anyone plz explain
thank u.


Normally, when you start a new Thread, the JVM will not terminate while that thread is running. This means you need to monitor it and terminate it yourself when you want to shut the application down.

A daemon thread, by contrast, will not stop the JVM from terminating. They are good for tasks such as regular monitoring of events, or periodic polling of external systems (amongst other uses). Because they don't stop the JVM from terminating, you can treat them as "fire-and-forget" - launch them once at startup and don't worry anymore.

The event-polling thread in a Swing or AWT application is an example of a daemon thread.

(The terminolgy comes from Unix - a daemon process is one that is detached from your normal terminal session)


Software is too expensive to build cheaply...
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Excellent overview. Robert put it so much better than the JavaDoc which says something backwards about the JVM can terminate when all threads that are not daemon threads have ended. You have to work out the missing wods that daemon threads will not prevent the JVM from terminating.


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
 
 
subject: what does daemon thread means?