Daemon Threads

Threads can be one of two types: a user thread or a daemon thread.

So what is a daemon? Well, Webster's Dictionary says it is "…an attendant spirit," or "…an inferior deity."

In a sense, Webster's is right in both cases with respect to daemon threads. Daemon threads usually perform a valuable service for the application by doing some task that the rest of the application doesn't really want to do. This may be personifying an application, but daemon threads usually end up performing tasks that, although important, are somewhat less critical to the application.

Daemon threads are also inferior to normal user threads. This is because as long as a user thread is running, the JVM will not stop an application. If there are only daemon ...

Get Special Edition Using Java 2 Standard Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.