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 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 daemon thread" Watch "what is daemon thread" New topic

what is daemon thread

anarkali perera
Ranch Hand

Joined: Sep 10, 2009
Posts: 237
what is daemon thread?
is it same as normal java thread?
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

A daemon thread is a normal thread that does not force the JVM to remain running. Put another way, the JVM will shut down when all non-daemon threads are finished running, regardless of whether there are daemon threads still running or not.

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

And just to be clear - when the JVM shuts down and daemon threads are still running, those daemon threads will be killed.
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
The thread we create are called user thread and when the main thread finishes its execution JVM will wait untill all the user thread completes.

But if it is the daemon thread then once your code lets say main thread is complete then JVM will not care about daemon thread and exit your program.

You can make user thread as daemon thread by calling setDaemon method.


Failure is not an option.
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

Also see here
I agree. Here's the link:
subject: what is daemon thread
It's not a secret anymore!