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

daemon threads

 
srinivas bolloju
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic