Java Multi-Threading Question:
Download Questions PDF

What is daemon thread and how it differs from user thread?

Answer:

A user thread is created by the application (user) while the daemon thread is created by the JVM to provide services to user threads.
If user threads are exists then only daemon threads exists.
You can make a user thread as daemon thread by using setDaemon(true) method.
In an application when only daemon threads are running (i.e. no user thread is running) then JVM will shut down the application and subsequently stops all daemon threads.
To keep the application running, at least one user thread should be running.

Download Java Multi-Threading Interview Questions And Answers PDF

Previous QuestionNext Question
Explain volatile?What is Thread leak?