• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is a daemon thread?

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone tell me what a daemon thread is? I've got no idea!
And what are the differences between user threads and daemon threads?
What should I know for the exam about daemon threads?
Thanks...
My Study Notes
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A daemon Thread is an ordinary Thread that has been marked using the setDaemon( boolean flag) method before it has been started. Daemon Threads are typically used for "housekeeping" chores.
The important thing to know is that the JVM will exit an application when only daemon Threads are left running.
There is an nice concise explanation in the JavaDocs for java.lang.Thread - you should get used to using the JavaDocs to answer questions like this.
Bill
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The garbage collection thread is a good example of a daemon thread and how they're used. They're a separate process that performs some task, but a daemon thread is automatically destroyed if all normal threads end. (For example, the garbage collection thread automatically stops if your applications stops.)
I hope that helps,
Corey
 
Karin Paola Illuminate
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Guys.
It is clear to me.
I forgot about the JavaDoc. You're right.
Thanks.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic