ITPUB
Dec 30, 2024 · Fundamentals
Why Does Thread.sleep(0) Appear in RocketMQ Code? Uncovering the Safepoint Trick
The article investigates a mysterious "prevent gc" comment in RocketMQ's source, explains how Thread.sleep(0) forces a JVM safepoint to mitigate long GC pauses, and demonstrates that changing loop counters from int to long eliminates the need for the hack.
Counted LoopJVMJava
0 likes · 22 min read
