JVM核心线程 [英] JVM Core Threads

查看:90
本文介绍了JVM核心线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的机器上启动JVM实例时,在 main()中运行无限睡眠的简单类,我看到四个关键线程(除主线程外) JVM:

On starting a JVM instance on my machine, with a simple class running infinite sleep in main(), I see four key threads (apart from the main thread) in the JVM:


  1. 附加监听器

  2. 参考处理程序

  3. 终结者

  4. 信号调度员

  5. DestroyJavaVM

  1. Attach Listener
  2. Reference Handler
  3. Finalizer
  4. Signal Dispatcher
  5. DestroyJavaVM

我很想知道每个核心JVM线程的用途。通过快速的互联网搜索,我在这些主题上找到了以下详细信息:

I am curious to understand purpose of each of these core JVM threads. From a quick internet search, I found the following details on these threads:


  1. 附加监听器:动态附加有
    中的连接侦听器线程是目标JVM。这是在第一个
    附加请求发生时启动的线程。

  2. 信号调度程序:当操作系统向JVM发出信号时,
    信号调度程序线程会将信号传递给相应的
    处理程序。

  3. 引用处理程序:将优先级挂起的高优先级线程
    参考。 GC创建一个简单的链接引用列表,需要处理
    ,并且该线程会快速将它们添加到正确的
    队列并通知ReferenceQueue侦听器。

  4. Finalizer :Finalizer线程调用终结器方法。

  5. DestroyJavaVM :此线程在程序退出时卸载Java VM。大部分时间都应该等待。

  1. Attach Listener: Dynamic attach has an attach listener thread in the target JVM. This is a thread that is started when the first attach request occurs.
  2. Signal Dispatcher: When the OS raises a signal to the JVM, the signal dispatcher thread will pass the signal to the appropriate handler.
  3. Reference Handler: High-priority thread to enqueue pending References. The GC creates a simple linked list of references which need to be processed and this thread quickly adds them to a proper queue and notifies ReferenceQueue listeners.
  4. Finalizer: The Finalizer thread calls finalizer methods.
  5. DestroyJavaVM: This thread unloads the Java VM on program exit. Most of the time it should be waiting.

我想知道这些线程的更多细节(或理解上的更正)参考文献(如果已知)。

I'd like to know further details (or correction in understanding) on these threads and reference documentation (if known).

推荐答案

你几乎已经做到了这一点,我要补充的唯一进一步澄清是使用attach侦听器线程(负责动态连接)。这不是通常使用的东西,但实际上允许另一个进程在运行的JVM中注入一个线程来查询有关VM如何运行的某些细节。它仅在两个Java VM之间实际使用(据我所见),例如在调试或分析时(或者某些IDE在运行时显示有关用户代码的其他信息)。

You've pretty much got that right, the only further clarification I'd add is with the attach listener thread (which is responsible for dynamic attach.) This isn't something that's usually used, but essentially allows another process to inject a thread inside the running JVM to query certain details about how the VM is running. It's only used in practice (as far as I've seen) between two Java VM's, such as when debugging or profiling (or in the case of some IDEs that display some other information about user code as it's running.)

请注意,所有这些线程都严重依赖于实现,并且不一定在其他VM上(或者甚至是同一VM的不同版本,或者具有不同选项的相同VM。)JVM可能会在启动时启动尽可能多的核心线程,其数量和类型(除主线程外)不受用户控制。

Note that all of these threads are heavily implementation dependent and aren't necessarily on other VM's (or even different versions of the same VM, or the same VM with different options.) The JVM may start up as many or as few core threads as it likes on launch, the number and type of those (aside from the main thread) are not under user control.

这篇关于JVM核心线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆