• 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

Daemon Thread

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should we know about daemon threads for the scjp1.4?
The kb book does not deal with that.
Can anyone who has taken the exam explain?


Thanks in advance..
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically this is all there is to know about daemon threads:

1. You can have two types of threads inside a Java program, user threads and daemon threads.
2. A Java program terminates when all USER threads have died, regardless of the existence of any living daemon threads.
3. You can change the status of a thread by using the setDaemon method as long as the thread has not been started. If you try to change a started thread, you'll get an IllegalThreadStateException.

Relevant methods:
final void setDaemon(boolean flag)
If flag is true, the thread will become a daemon thread. Otherwise the thread becomes a user thread. (BTW, threads are created as user threads initially)

final boolean isDaemon()
Returns true if the thread is a daemon thread; false if it is a user thread.

Hope this helps.
 
shri mon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic