aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt on setDeamon(). 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 "Doubt on setDeamon()." Watch "Doubt on setDeamon()." New topic
Author

Doubt on setDeamon().

Xiao Song
Greenhorn

Joined: Aug 29, 2006
Posts: 17
Code as follows:

Why there is no output? What does setDeamon() do?
Thanks advance!


scjping.......
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8813
    
    5
Well setDaemon isn't on the exam, so go to the next question, or see if you can refactor this code without setDaemon


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

Joined: Apr 29, 2006
Posts: 106
Daemmon threads are just service providers to other User threads.A daemon thread is stopped if there are no other user threads are running.When an application starts,a user thread is automatically executed to run the main() method & other threads are spawned from this main thread.
In your code the other thread that is created is a daemon thread & hence once the main thread finishes the execution ,program terminates.
Abdul Rehman
Ranch Hand

Joined: Nov 07, 2006
Posts: 65
Originally posted by Bert Bates:
Well setDaemon isn't on the exam, so go to the next question, or see if you can refactor this code without setDaemon

I am always hungry for such posts...
Xiao Song
Greenhorn

Joined: Aug 29, 2006
Posts: 17
thanks all..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt on setDeamon().