Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query about Daemon thread.

 
Ganesh Prakhya
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now its clear to me. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic