Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does java "VM thread" do?

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% CPU usage and most of CPU time

like image 885
smallnest Avatar asked Oct 09 '10 06:10

smallnest


People also ask

What is a JVM thread?

A Java thread is the execution path in a program. Everything that runs in Java is run in threads. Every application in the JVM world has threads, at least one, even if you don't call it explicitly. It all starts with the main method of your code, which is run in the main application thread.

How many threads can a Java VM support?

Each JVM server can have a maximum of 256 threads to run Java applications.

How does multithreading work in JVM?

To coordinate shared data access among multiple threads, the Java virtual machine associates a lock with each object and class. A lock is like a privilege that only one thread can "possess" at any one time. If a thread wants to lock a particular object or class, it asks the JVM.

What is the use of thread dump in Java?

A thread dump is a snapshot of the state of all the threads of a Java process. The state of each thread is presented with a stack trace, showing the content of a thread's stack. A thread dump is useful for diagnosing problems, as it displays the thread's activity.


1 Answers

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.

like image 134
Avi Avatar answered Sep 30 '22 01:09

Avi