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