wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes 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 "daemon threads" Watch "daemon threads" New topic
Author

daemon threads

srinivas bolloju
Ranch Hand

Joined: Jan 23, 2001
Posts: 112
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
pls let me know correct answers for this above.
in my opinion, threads which we create for simple tasks using setdaemon() are daemon threads, how are these different from user threads and application threads?, when only daemon threads are running then the interpreter will exit.with that e) is true, what about other stuff?
pls help


please use the [code][/code] tags when showing code. visit <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=ubb_code_page" target="_blank" rel="nofollow">http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=ubb_code_page</a> ,for more details
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by srinivas bolloju:
a) Daemon threads can not be destroyed

Why not? They're just like a user thread. They can complete, be interrupted, etc.

b) Running User threads prevent a JVM from terminating program

True. As long as a single user thread is alive and running, the JVM will not exit.

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

This is wrong - review the statement above.

d) Daemon threads can not be grouped together

I'm no expert but, as I see that the class ThreadGroup has a method named "isDaemon()", I'm guess that daemon threads can be grouped.

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

True. This was already covered in "c".
I hope that helps,
Corey
[ August 14, 2002: Message edited by: Corey McGlone ]

SCJP Tipline, etc.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: daemon threads