Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

daemon threads

 
RAVI BHAWNANI
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why do daemon threads keep on running even when we are delieberately killing the execution of main thread
 
Rahul Mahindrakar
Ranch Hand
Posts: 1868
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not true. Daemon threads are killed once all the user threads have exited.
Check out the code example below. This example basically creates a daemon thread which is in a while(true) loop to print out "in Daemon thread". If Daemon threads

keep on running even when we are delieberately killing the execution of main thread

then this program should keep printing "in Daemon thread" forever. However this is not so.
 
RAVI BHAWNANI
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks .i have received your mail
soon will be back with new query
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic