如何在没有ThreadGroup的情况下创建线程?
How to create a thread without ThreadGroup?
这个问题是在面试高级开发人员角色时提出的。
因为我没有接触过 Java 多线程和并发。所以,我无法回答这个问题。
Every thread we create is part of a ThreadGroup. Then how do we create
a thread without ThreadGroup?
没有 ThreadGroup 就无法创建线程。
有关详细信息,请查看此处:https://www.eg.bucknell.edu/~mead/Java-tutorial/essential/threads/group.html
"If you create a new Thread without specifying its group in the
constructor, the runtime system automatically places the new thread in
the same group as the thread that created it (known as the current
thread group and the current thread, respectively). So, if you leave
the thread group unspecified when you create your thread, what group
contains your thread?
When a Java application first starts up, the Java runtime system
creates a ThreadGroup named main. Unless specified otherwise, all new
threads that you create become members of the main thread group."
这里:http://www.java2s.com/example/java-book/thread-group.html
这个问题是在面试高级开发人员角色时提出的。 因为我没有接触过 Java 多线程和并发。所以,我无法回答这个问题。
Every thread we create is part of a ThreadGroup. Then how do we create a thread without ThreadGroup?
没有 ThreadGroup 就无法创建线程。
有关详细信息,请查看此处:https://www.eg.bucknell.edu/~mead/Java-tutorial/essential/threads/group.html
"If you create a new Thread without specifying its group in the constructor, the runtime system automatically places the new thread in the same group as the thread that created it (known as the current thread group and the current thread, respectively). So, if you leave the thread group unspecified when you create your thread, what group contains your thread?
When a Java application first starts up, the Java runtime system creates a ThreadGroup named main. Unless specified otherwise, all new threads that you create become members of the main thread group."
这里:http://www.java2s.com/example/java-book/thread-group.html