Daemon threads on SCJP v1.4 exam

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?

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?

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.

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.

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.

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:

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.