JVM中的哪个JavaThread是mutator线程?

Which JavaThread in JVM is mutator thread?

mutator 线程的概念与垃圾收集有关。

Hotspot 中的基本线程模型是 Java 线程(java.lang.Thread 的实例)和本机操作系统线程之间的 1:1 映射。

What do the different (HotSpot) JVM thread types do?

hotspot/src/share/vm/runtime/thread.hpp

// Class hierarchy
// - Thread
//   - NamedThread
//     - VMThread
//     - ConcurrentGCThread
//     - WorkerThread
//       - GangWorker
//       - GCTaskThread
//   - JavaThread
//     - various subclasses eg CompilerThread, ServiceThread
//   - WatcherThread

JavaThread 是离 mutator 线程最近的一个。但是,JavaThread 有一些 children 类:

我不认为 CodeCacheSweeperThread、CompilerThread、jmitiAgentThread 是 mutator 线程...但是 ServiceThread 怎么样?

此外,我认为CompilerThread应该是JVM的内部线程而不是mutator线程。

如何区分一个mutator线程是Java程序,说哪个线程服务于下面的单线程程序(1:1映射)?

public class HelloWorld {

    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");
    }

}

The concept of mutator thread is related to Garbage Collection.

AFAIK,这不是一个通常与 Java 相关的术语,因为假定每个线程都能够修改堆。有一些例外,例如编译器线程只修改本机代码翻译。

一般来说,我假设任何线程都可以修改状态,除非您有特定理由不相信。

它与 JVM internal threads 相关,更准确地说是与 GC 相关。