seniorKotlin

How do Kotlin coroutines behave during JVM safepoints and GC pauses?

Updated May 16, 2026

Short answer

Coroutines are paused indirectly during JVM safepoints and GC because threads are halted at execution points.

Deep explanation

The JVM periodically introduces safepoints where all application threads are paused for GC, deoptimization, or class unloading. Kotlin coroutines do not bypass this because they run on JVM threads. When a safepoint occurs, all running coroutines are paused regardless of their state. This can cause latency spikes in coroutine-heavy systems, especially when GC is frequent due to allocation-heavy code. The coroutine scheduler resumes execution after safepoint completion.

Unlock with a Pro subscription to view this section.

View pricing

Real-world example

No real-world example available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Common mistakes

No common mistakes listed yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

Follow-up questions

No follow-up questions available yet.

Unlock with a Pro subscription to view this section.

Upgrade to Pro

More Kotlin interview questions

View all →