Back

Explore Courses Blog Tutorials Interview Questions
0 votes
12 views
in Java by (830 points)
Can anybody tell me what daemon threads are in Java?

1 Answer

0 votes
by (13.2k points)

Daemon thread is defined as a service provider thread which provides services to the user thread. Its life depends on the user threads i.e. when all the user threads dies, JVM terminates this thread by regulation. An example for a daemon thread would be the garbage collection.

When all non-daemon threads finish, the JVM tends to halt, and any remaining daemon threads are abandoned, finally blocks are not executed. Due to this reason they must be used carefully. setDaemon(boolean) method can be used to change the Thread daemon properties before the thread starts which can be very useful.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...