What is a "system thread" in Java?

Viewed 325

In Eclipse Debug View, there is an option to "Show System Threads":

enter image description here

When enabled, Eclipse shows a number of threads that are normally hidden from the thread list. They are all under the system thread group:

enter image description here

My question is, is there an official concept of "system thread" in Java, or is this just an Eclipse thing? I have Googled for a while and found no mention of "Java system thread", so I guess this is an Eclipse-made terminology?

If that isn't the case and this is a Java concept like daemon thread, how do I know if a given thread is a "system" one?

Another thing that I don't understand is, if I create a new thread group Foo under the root system thread group, and then create a new thread MyThread under the Foo group

public class Test2 {

    public static void main(String[] args) {
        ThreadGroup threadGroup = new ThreadGroup(getRootThreadGroup(), "Foo");
        new Thread(threadGroup, () -> {
            System.out.println("hello");
        }, "MyThread").start();
    }

    // This will return the root "system" thread group
    public static ThreadGroup getRootThreadGroup () {
        ThreadGroup currentGroup = Thread.currentThread().getThreadGroup();
        while (currentGroup != null) {
            ThreadGroup parent = currentGroup.getParent();
            if (parent == null) {
                return currentGroup;
            }
            else {
                currentGroup = parent;
            }
        }

        return null;
    }
}

then Eclipse shows that MyThread is a system thread:

enter image description here

So in this case is Eclipse mistaking my thread as a "system thread", or is this an actual way of creating a "system thread", whatever that is?

0 Answers
Related