What does java “VM thread” do?

后端 未结 3 2059
盖世英雄少女心
盖世英雄少女心 2020-12-11 17:33

I use jstack to output the thread info. And there is a thread: \"VM Thread\" prio=10 tid=0x0878b400 nid=0x760a runnable

What is this thread used to do? It takes 50%

相关标签:
3条回答
  • 2020-12-11 17:55

    The VM thread is defined here as:

    This thread waits for operations to appear that require the JVM to reach a safe-point. The reason these operations have to happen on a separate thread is because they all require the JVM to be at a safe point where modifications to the heap can not occur. The type of operations performed by this thread are "stop-the-world" garbage collections, thread stack dumps, thread suspension and biased locking revocation.

    There's also some information provided in a de-duplicated SO answer here.

    0 讨论(0)
  • 2020-12-11 17:58

    How do you know that this thread is taking 50% usage? Being runnable doesn't mean its consuming cpu.

    AFAIK this is used for internal java operation, possibly involved in GC.

    Which version of java are you using? I would check you have an up to date version of Java and see if this still happens.

    I would suggest you memory profile your application to see how much objects you are creating and see if you can reduce your object count to reduce any GC work load.

    0 讨论(0)
  • 2020-12-11 18:07

    I think it is the Garbage Collection thread. It does Garbage Collection.

    0 讨论(0)
提交回复
热议问题