my dog learned polymorphism
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes what is daemon threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "what is daemon threads" Watch "what is daemon threads" New topic

what is daemon threads

Karu Raj
Ranch Hand

Joined: Aug 31, 2005
Posts: 481
what is daemon threads
Kavitha Govindaraj

Joined: May 27, 2004
Posts: 28
Any Java thread can be a daemon thread. Daemon threads are service providers for other threads running in the same process as the daemon thread. For example, the HotJava browser uses up to four daemon threads named "Image Fetcher" to fetch images from the file system or network for any thread that needs one. The run() method for a daemon thread is typically an infinite loop that waits for a service request.

When the only remaining threads in a process are daemon threads, the interpreter exits. This makes sense because when only daemon threads remain, there is no other thread for which a daemon thread can provide a service.

To specify that a thread is a daemon thread, call the setDaemon() method with the argument true. To determine if a thread is a daemon thread, use the accessor method isDaemon().

Thanks <br />Kavitha G <br />SCJP
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
Garbage collection thread is a deamon thread.

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
wood burning stoves
subject: what is daemon threads
It's not a secret anymore!