aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what are daemon threads? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what are daemon threads?" Watch "what are daemon threads?" New topic
Author

what are daemon threads?

srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252
hi frnds ,

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



Thanks & Regards<br /> <br />-Srikanth
Santana Iyer
Ranch Hand

Joined: Jun 13, 2005
Posts: 335
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

Joined: Jul 28, 2005
Posts: 252
thanks a lot ....Santana Iyer ..

answer also given was d...
srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252
thanks a lot ....Santana Iyer ..

answer also given was d...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what are daemon threads?