Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Daemon threads on SCJP v1.4 exam

 
Amanda Albert
Ranch Hand
Posts: 41
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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,

Amanda
 
Chris Hendy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See definition given at

http://faq.javaranch.com/view?MultiThreading
 
Henry Wong
author
Marshal
Pie
Posts: 21506
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Henry
 
Amanda Albert
Ranch Hand
Posts: 41
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


Yours,
Bu.
 
Amanda Albert
Ranch Hand
Posts: 41
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Sheriff
Posts: 8900
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

Bert
 
Amanda Albert
Ranch Hand
Posts: 41
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

Amanda
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic