File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes daemon thread. 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 "daemon thread." Watch "daemon thread." New topic

daemon thread.

jaman tai
Ranch Hand

Joined: Sep 26, 2005
Posts: 37
With respect to User and Daemon threads:

a) Daemon threads can not be destroyed

b) Running User threads prevent a JVM from terminating program

c) Running Daemon threads prevent a Java VM from terminating program

d) Daemon threads can not be grouped together

e) The JVM can terminate program when only daemon threads are running

answer: b, e? why e is correct?
Pranav Shukla
Ranch Hand

Joined: Oct 05, 2005
Posts: 64
Daemon threads exist only to serve User threads. Typically they will provide services to the User Threads and User Threads will do the real "work" in the program.

So if there doesn't exist any live User Thread, the JVM may choose to terminate the program even if there are daemon threads running.

Pranav Shukla
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You can find out why e is correct by looking up the definition of a Daemon thread.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: daemon thread.
It's not a secret anymore!