wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Another JQ+ Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Another JQ+ Thread " Watch "Another JQ+ Thread " New topic
Author

Another JQ+ Thread

Vikrama Sanjeeva
Ranch Hand

Joined: Sep 02, 2001
Posts: 756
Question ID :952739431260
Which of the following is true?
1:A program ends when all daemon threads end
2:A program ends when all non-daemon threads ends
3:A daemon thread is a low priority thread that never stops but keeps running in the back ground
4:A user thread cannot stop the non-user or daemon thread.
Correct Ans:2
JQ+ Explanation:
Daemon threads are meant to perform supporting tasks that make sense only if normal threads are running.
For eg. the Garbage Collecter thread is usefull only if some user thread is running. If all the user threads end then what is the use of GC thread? So the program should end when all the non-daemon threads end.
You can make any Thread (if you have permission) a daemon thread by calling setDaemon(true);
You can stop any thread.
**************************************************************
It says that What is the use of GC thread if all the user threads ends.If there is no use then who will GC the user threads which has died?
A/C to me option 3 is correct.
Bye
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!


Count the flowers of your garden, NOT the leafs which falls away!
Prepare IBM Exam 340 by joining http://groups.yahoo.com/group/IBM340Exam/
Phil Sharp
Ranch Hand

Joined: Nov 08, 2001
Posts: 40
I agree with the test although not sure about their wording
2. Is correct because when all non-deamon threads finish the program ends. A deamon thread comes to an end when the thread that created it ends, if all non-deamon threads have finished it implies the thread that created it has finished (might go through other deamon threads but eventually will get to a non-deamon thread). However it might not appear to occur immediately due to switching between threads
3. Is incorrect as a deamon thread is still a thread, it may naturally come to an end itself or be interrupted just like any other thread, it does not need to be a continuous loop. In fact thinking about it, it automatically comes to an end when the thread that created it comes to an end which could happen at any time.
Phil
Vikrama Sanjeeva
Ranch Hand

Joined: Sep 02, 2001
Posts: 756
Phil try to understand my question.

It says that What is the use of GC thread if all the user threads ends.If there is no use then who will GC the user threads which has died?

Bye.
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Another JQ+ Thread