File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Daemon threads on SCJP v1.4 exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Daemon threads on SCJP v1.4 exam" Watch "Daemon threads on SCJP v1.4 exam" New topic

Daemon threads on SCJP v1.4 exam

Amanda Albert
Ranch Hand

Joined: Jun 12, 2006
Posts: 41


In addition to the Sierra and Bates 2003 study guide, I'm using Enthuware's JQPlus V4 practice exam product as part of my preparation for the exam. There was a question about daemon threads in JQPlus. I had never heard of a daemon thread before, and was jolted a bit because daemon threads weren't covered in the study guide. So can you please give me a brief explanation, in case they show up on the exam?



Sun Certified Programmer for the Java 2 Platform 1.4
Chris Hendy
Ranch Hand

Joined: Mar 04, 2006
Posts: 98
See definition given at
Henry Wong

Joined: Sep 28, 2004
Posts: 20538

Wow... how the heck did that FAQ go unchecked for so long???

... wait a sec ...

Okay, it's fixed now. It is still poorly written, but at least it is no longer blantantly incorrect.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Amanda Albert
Ranch Hand

Joined: Jun 12, 2006
Posts: 41

Thanks for your responses, but I still don't understand what a daemon thread is. The link you sent me to only says that "the JVM will exit when there are only daemon threads running." Why? What is a daemon thread?
Carol Enderlin
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Google is your friend

Basic Thread operations in java talks about daemon threads:

Daemon threads are designed as low-level background threads that perform useful work. However, it is not essential that they be allowed to complete before an application terminates. One example of a daemon thread is the garbage collector thread.

Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi ranchers,

Amanda Albert posted November 25, 2006 02:07 PM
So can you please give me a brief explanation, in case they show up on the exam?

Seems to be your first posting here, so welcome to the Ranch!

I think the fact, that a daemon (unlike a normal thread) is not gurantied to run its run() method to completion is the most important fact.
Perhaps try this example:
The run method is synchronized so the treads run one after another. Required in the example, but not genarally for daemons.

To make a Daemon, the setDaemon(boolean) method is used.
This must be done before starting the thread.

One little thing left: if you make a thread from within a daemon, the resulting thread will also be a daemon.


all events occur in real time
Amanda Albert
Ranch Hand

Joined: Jun 12, 2006
Posts: 41

Thanks so much!

I'm wondering how Sierra and Bates decided what was important to know for the exam (and hence made it into the study guide). The study guide was recommended to me by two co-workers, and believe me, it has helped a great deal. But I was spun a little bit when the daemon question came up and I was wholly unprepared.
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
I'm usually pretty confident about what's in the exam and what isn't. In this case I'm about 95% sure that daemon threads aren't on the 1.4 exam. IF they are on the exam, they are treated like any other thread, and their special behaviors will not be part of the question. I think that in older versions of the exam (like the 1.2) daemon threads were covered, and so I think a lot of 3rd party mocks include them in their questions. (It might also be that Sun's own epractice exam contains daemon questions, but I still think they're not on the real exam.)

In any case, if I'm wrong, the concept of a "daemon" thread will play an incredibly small role.

Sorry I'm having a memory lapse here - this is the kind of thing where I wouldn't bet my life, but I would bet $20 - fwiw. :roll:


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Amanda Albert
Ranch Hand

Joined: Jun 12, 2006
Posts: 41

Thanks for your response Bert!

I had a feeling that perhaps JQPlus might have been pulling questions from previous exams which had a different focus. A co-worker who has taken the exam mentioned that there were a lot of questions on threads, and that happened to be a topic I was struggling with, so I wanted to be sure I had all the information I needed.

Thanks again!

Wish me luck, as my exam is tomorrow!

I agree. Here's the link:
subject: Daemon threads on SCJP v1.4 exam
It's not a secret anymore!