JVM Core Threads

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:

  • Attach Listener
  • Reference Handler
  • Finalizer
  • Signal Dispatcher
  • DestroyJavaVM
  • 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:

  • 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.
  • Signal Dispatcher : When the OS raises a signal to the JVM, the signal dispatcher thread will pass the signal to the appropriate handler.
  • 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.
  • Finalizer : The Finalizer thread calls finalizer methods.
  • 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).


    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.)

    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.

    链接地址: http://www.djcxy.com/p/16714.html

    上一篇: 神秘崩溃(NSAttributedString,iOS 7)

    下一篇: JVM核心线程