User thread versus daemon
There is a particular kind of thread called a daemon.
Note
The word daemon has an ancient Greek origin, meaning a divinity or supernatural being of nature between gods and humans and an inner or attendant spirit or inspiring force.
In computer science, the term daemon has more mundane usage and is applied to a computer program that runs as a background process, rather than being under the direct control of an interactive user. That is why there are the following two types of threads in Java:
- User thread (default) initiated by an application (the main thread is one such example)
- Daemon thread that works in the background in support of user-thread activity
That is why all daemon threads exit immediately after the last user thread exits or are terminated by the JVM after an unhandled exception.