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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.