jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Daemon Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Daemon Thread" Watch "Daemon Thread" New topic
Author

Daemon Thread

shri mon
Ranch Hand

Joined: Jan 11, 2005
Posts: 63
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..
Ren� Star
Greenhorn

Joined: Feb 24, 2005
Posts: 13
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

Joined: Jan 11, 2005
Posts: 63
Thanks a lot.
 
jQuery in Action, 2nd edition
 
subject: Daemon Thread
 
Similar Threads
"Top Ten Topics that Everyone Thinks are on the SCJP Exam, but Aren't "- Bert Bates
what is daemon threads
Priority of Daemon threads
Daemon
regarding threads