aspose file tools*
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
Author

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
Bartender

Joined: Jan 28, 2003
Posts: 3956
    
  17

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
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3956
    
  17

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.


SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

Also see here


http://muhammadkhojaye.blogspot.com/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is daemon thread
 
Similar Threads
A few questions ...
Daemon Thread
Daemon Thread
Daemon threads
Daemon threads & non daemon Threads