wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Query about Daemon thread. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Query about Daemon thread." Watch "Query about Daemon thread." New topic
Author

Query about Daemon thread.

Ganesh Prakhya
Ranch Hand

Joined: May 05, 2004
Posts: 76
Hi,

Can anybody explain me the difference between User Thread and Daemon Thread in terms of execution?

Thanks in advance,
Ganesh
patrick J. d'cousta
Greenhorn

Joined: Oct 25, 2005
Posts: 24
The only diffrence between daemon thread and user thread is daemon threads are for serving user threads.That is if all the user threads get over then all the daemon thread are terminated and application exits.

Example garbage collector thread
Ganesh Prakhya
Ranch Hand

Joined: May 05, 2004
Posts: 76
Hi patrick J. d'cousta,

But, if I create an user thread and a daemon thread, what advantages I have with daemon thread over user thread? In otherwords, when we need to create/use daemon threads?

Thanks in advance,
Ganesh..
patrick J. d'cousta
Greenhorn

Joined: Oct 25, 2005
Posts: 24
Ganesh
Imagine u are writing a application where there are two tasks

1.Number of thread do some work and dump the output in a directory
2.One thread is supposed to run once a while and purge this output

1 are all user threads
2 is a daemon thread.
Ganesh Prakhya
Ranch Hand

Joined: May 05, 2004
Posts: 76
Now its clear to me. Thank you.
 
Don't get me started about those stupid light bulbs.
 
subject: Query about Daemon thread.