Eclipse Debugger: Threads vs "Daemon" Threads

daemon, debugging, eclipse, java, multithreading

Solution

Daemon threads in Java are threads that run in the background (mostly created by the JVM) for performing background tasks (like garbage collection). The main difference between a daemon thread and a user thread is that as soon as all user threads finish execution Java terminates itself. JVM doesn't wait for daemon threads to finish their execution.

Note that you can make a thread created by a user thread to be a daemon thread by `setDaemon(true)` (and it must be called before the thread's `start()` method is called). In order for a program to continue running, it must always have at least one live user thread.

Eclipse, like you, can easily check whether a thread `isDaemon()` or not.

Problem

Anytime I run a debug configuration in Eclipse (a "debugging session"), and I switch over to the Debug Perspective, I always see "Threads" as well as "Daemon Threads" in the call stack view. Why are some threads daemons and other just POTs (plain-old-threads)? Thanks in advance! (Note: I'm not asking what daemons are, or what daemon threads are, just how Eclipse determines which threads are daemons.)

Original source