Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what are daemon threads?

 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi frnds ,

what are daemon threads??
can anyone give some properties of daemon threads so that i can answer this question?

 
Santana Iyer
Ranch Hand
Posts: 335
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If main thread ends if there are still non daemon thread present than program will keep running.

If there are only daemon thread present than as soon as main thread completes program ends.

What is daemon thread?
before you start a thread you can set it as daemon thread by

setDaemon(boolean value)

if thread is daemon it only runs as long as other user threads have not completed.


b. A program will terminate only when all user threads stop running

is true statement.

daemon thread are generally present to support other thread they run in background for e.g. say garbage collector thread if program stops executing main ends now there is no point in running gc thread as program stops and OS will reclaim memmory. however program does not finish executing as long as there is non daemon thread present.
[ September 09, 2005: Message edited by: Santana Iyer ]
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot ....Santana Iyer ..

answer also given was d...
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot ....Santana Iyer ..

answer also given was d...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic