Tagged articles
15 articles
Page 1 of 1
dbaplus Community
dbaplus Community
Apr 19, 2025 · Fundamentals

Why Thread.sleep(0) Can Influence GC: Uncovering JVM Safepoint Tricks

This article explores the puzzling "prevent gc" comment in RocketMQ source code, explains how Thread.sleep(0) interacts with JVM safepoints, distinguishes counted and uncounted loops, and demonstrates practical experiments that reveal why altering loop variables can change GC behavior.

JVMJavaRocketMQ
0 likes · 12 min read
Why Thread.sleep(0) Can Influence GC: Uncovering JVM Safepoint Tricks
Programmer DD
Programmer DD
Aug 1, 2023 · Fundamentals

Why Thread.Sleep(0) Can Change Your App’s Responsiveness – The Real Reason

Thread.Sleep pauses a thread for a specified time, but its behavior depends on OS scheduling; Sleep(0) yields the CPU to let other threads run, while Sleep(1000) doesn’t guarantee immediate wake‑up, illustrating how time‑slice and priority‑based scheduling affect thread execution.

CCPU schedulingpreemptive multitasking
0 likes · 10 min read
Why Thread.Sleep(0) Can Change Your App’s Responsiveness – The Real Reason
Su San Talks Tech
Su San Talks Tech
Sep 17, 2022 · Fundamentals

Why Does Thread.sleep(0) Prevent GC? Uncovering JVM Safepoint Tricks

This article examines a puzzling 'prevent gc' comment in RocketMQ source, explains how inserting Thread.sleep(0) creates a JVM safepoint to avoid long GC pauses, explores counted vs uncounted loops, and demonstrates practical code modifications to improve performance.

Garbage CollectionJVMJava performance
0 likes · 13 min read
Why Does Thread.sleep(0) Prevent GC? Uncovering JVM Safepoint Tricks
FunTester
FunTester
Sep 25, 2020 · Operations

Mastering Selenium Waits: Implicit, Explicit, Fluent & Thread.Sleep Explained

This article explains why waiting is essential in Selenium automation, compares Thread.sleep with implicit, explicit, and fluent waits, provides detailed Java code examples for each approach, and highlights best‑practice recommendations for reliable web element interaction.

Explicit WaitImplicit WaitJava
0 likes · 14 min read
Mastering Selenium Waits: Implicit, Explicit, Fluent & Thread.Sleep Explained
macrozheng
macrozheng
Jun 10, 2020 · Fundamentals

What Does Thread.Sleep(0) Actually Do? Unveiling Thread Scheduling Basics

This article explains the purpose of Thread.Sleep, clarifies common misconceptions about its timing behavior, compares Unix time‑slice and Windows preemptive scheduling using a cake‑eating analogy, and shows why Thread.Sleep(0) can trigger an immediate CPU‑competition reschedule to improve responsiveness.

CPU schedulingOperating Systempreemptive multitasking
0 likes · 10 min read
What Does Thread.Sleep(0) Actually Do? Unveiling Thread Scheduling Basics
Java Backend Technology
Java Backend Technology
Jun 4, 2020 · Fundamentals

What Really Happens When You Call Thread.Sleep(0)? OS Scheduling Explained

Thread.Sleep pauses a thread for a specified time, influencing CPU competition; understanding its behavior—including the surprising effects of Sleep(0) and how operating systems schedule threads via time‑slicing or preemptive strategies—reveals why Sleep can affect responsiveness and why it’s used in tight loops.

CPU schedulingOperating Systemthread-sleep
0 likes · 10 min read
What Really Happens When You Call Thread.Sleep(0)? OS Scheduling Explained