Java Multi-Threading Question:
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.
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.
Previous Question | Next Question |
Explain volatile? | What is Thread leak? |