In Java, Daemon Threads are one of the types of the thread which does not prevent Java Virtual Machine (JVM) from exiting.The main purpose of a daemon thread is to execute background task especially in case of some routine periodic task or work. With JVM exits, daemon thread also dies.
By setting a thread.setDaemon(true)
, a thread becomes a daemon thread. However, you can only set this value before the thread start.