JVM virtual machine thread

JVM virtual machine thread

  • A thread is a unit of operation in a program. JVM allows an application to be executed in parallel by multiple threads.
  • In the Hotspot JVM, each thread is directly mapped to the native thread of the operating system. When a Java thread is ready for execution, a native thread of the operating system is also created at the same time. After the Java thread execution terminates, the local thread will also be recycled.
  • The operating system is responsible for the scheduling of all threads to any available CPU. Once the local thread is initialized successfully, it will call the run () method in the Java thread.
  • Daemon thread, ordinary thread (specific differences, new instructions will follow)

JVM system thread

If you use jconsole or any debugging tool, you can see that there are many threads running in the background. These background threads do not include the main thread that calls public static void main(string[]) and all threads created by the main thread. These main background system threads are mainly the following in Hotspot JVM:

  • Virtual machine thread: The operation of this thread only appears when the JVM reaches a safe point. The
    reason these operations must occur in different threads is that they all require the JVM to reach a safe point so that the heap does not change. The
    execution type of this thread includes "stop-the-world" garbage collection, thread stack collection, thread suspension, and
    biased lock cancellation.
  • Periodic task threads: These threads are the embodiment of time-period events (such as interrupts), and they are generally used
    to schedule execution of periodic operations.
  • GC thread: This thread provides support for different types of garbage collection behavior in the JVM.
  • Compiler thread: This thread compiles bytecode into native code at runtime.
  • Signal scheduling thread: This thread receives signals and sends them to the JVM, and
    processes them by calling appropriate methods within it .

Guess you like

Origin blog.csdn.net/qq_37924905/article/details/108614436