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
posted
0
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
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.