Fundamentals 7 min read

Inside the JVM: Roles of Internal Threads like FinalizerThread, AppClassLoader, and VMThread

The article anthropomorphizes several JVM internal threads—FinalizerThread, AppClassLoader, ReferenceHandler, and VMThread—detailing how they handle object finalization, class loading, special reference queues, and VM operations, providing a whimsical yet informative overview of JVM internals.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
Inside the JVM: Roles of Internal Threads like FinalizerThread, AppClassLoader, and VMThread

The article anthropomorphizes several internal JVM threads—Anonymous User, FinalizerThread, AppClassLoader, ReferenceHandler, and VMThread—explaining their responsibilities in object finalization, class loading, reference handling, and VM operations.

FinalizerThread manages objects that implement the finalize method, creating a Finalizer object linked to a ReferenceQueue and a static FinalizerThread that processes the queue.

AppClassLoader, part of the class‑loading department, loads .class files into memory and follows the parent‑delegation model, delegating to ExtClassLoader and BootstrapClassLoader , though the delegation can cause delays.

ReferenceHandler, another GC‑department engineer, deals with special Java references (FinalReference, SoftReference, WeakReference, PhantomReference) and enqueues them for processing.

VMThread operates at the native layer, pulling VM_Operation objects from a VMOperationQueue and executing various VM tasks such as thread dumps, safepoint synchronization, and garbage‑collection triggers. Example macro definitions and the Mode enum illustrate the range of operations:

#define VM_OPS_DO(template) \
  template(None) \
  template(ThreadStop) \
  template(ThreadDump) \
  template(PrintThreads) \
  template(FindDeadlocks) \
  template(ClearICs) \
  template(ForceSafepoint) \
  template(ForceAsyncSafepoint) \
  template(Deoptimize) \
  template(DeoptimizeFrame) \
  template(DeoptimizeAll) \
  template(ZombieAll) \
  template(Verify) \
  template(PrintJNI) \
  template(HeapDumper) \
  template(DeoptimizeTheWorld) \
  template(CollectForMetadataAllocation) \
  template(GC_HeapInspection) \
  template(GenCollectFull) \
  template(GenCollectFullConcurrent) \
  template(GenCollectForAllocation) \
  template(ParallelGCFailedAllocation) \
  template(ParallelGCSystemGC) \
  …
enum Mode {
_safepoint,      // blocking, safepoint
_no_safepoint,   // blocking, no safepoint
_concurrent,     // non-blocking, no safepoint
_async_safepoint // non-blocking, safepoint
};

The piece concludes with a brief note encouraging sharing and includes promotional links unrelated to the technical content.

JVMgarbage collectionthreadFinalizeJava Internals
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.