Multithreading Interview Questions
6. What's the difference between User thread and Daemon
thread?
User and Daemon are basically two types of thread used in Java by using a ‘Thread
Class’.
User Thread (Non-Daemon Thread): In Java, user threads have a specific life cycle
and its life is independent of any other thread. JVM (Java Virtual Machine) waits for
any of the user threads to complete its tasks before terminating it. When user threads
are finished, JVM terminates the whole program along with associated daemon
threads.
Daemon Thread: In Java, daemon threads are basically referred to as a service
provider that provides services and support to user threads. There are basically two
methods available in thread class for daemon thread: setDaemon() and isDaemon().
User Thread vs Daemon Thread
Dostları ilə paylaş: