A daemon thread is a thread, that does not prevent the JVM from exiting when the program finishes but the thread is still running. An example for a daemon thread is the garbage collection.
You can use the setDaemon() method to change the Thread daemon properties.When a new thread is created it inherits the daemon status of its parent.
Normal thread and daemon threads differ in what happens when they exit. When the JVM halts any remaining daemon threads are abandoned:
finally blocks are not executed,
stacks are not unwound - the JVM just exits.
Due to this reason daemon threads should be used sparingly and it is dangerous to use them for tasks that might perform any sort of I/O.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Can you answer this question?
Write Answer1 Answers