• Post Reply Bookmark Topic Watch Topic
  • New Topic

Daemon Threads in java

 
Deepika Saxena
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Daemon threads are the low priority threads in java. example is garbage collector. I read that only JVM or OS will have control on Daemon threads.
could any body please tell me can we create our own Daemon Threads in java? if yes, how to do it?
Thanks.
--Deepika
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thread class has a convenient method setDaemon(boolean isDaemon).
Not a beginners topic. I will move this thread to a more appropriate forum for you.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whether or not a thread is a daemon thread is independent of its priority (although it's true that most often they have a low priority). Check the javadocs of the java.lang.Thread class for methods that can be used to set/unset the daemon status of a thread.

All that being a daemon means for a running Thread is that it will not keep the JVM from exiting if there are no other non-daemon threads; no more, no less.
 
Deepika Saxena
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Maneesh and Ulf for clarifying this Thread.
--Deepika
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!