Java / JVM Architecture (Java21) Interview questions
What is the difference between stop-the-world pauses and concurrent GC phases?
Garbage collectors mix two kinds of work, and the balance between them is what defines a collector's pause-time behavior.
| Stop-the-world (STW) | Concurrent |
| All application ("mutator") threads are paused | Application threads keep running alongside GC work |
| Used when the heap must be in a guaranteed-consistent state, e.g. root scanning or some compaction steps | Used for work that can tolerate the heap changing underneath it, using techniques like SATB (snapshot-at-the-beginning) marking and read/write barriers |
| Directly adds to observed application pause time | Adds background CPU cost, but not paused-thread latency |
Modern collectors like G1, ZGC, and Shenandoah are built to push as much work as possible into the concurrent category, leaving only short, bounded STW pauses for the parts that genuinely require it.
More Related questions...