Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardKotlincoroutine cancellation cooperationSingle-choice MCQ

Why does a tight CPU loop like `while (i < n) { i++ }` inside a coroutine fail to stop when the coroutine is cancelled, even though `delay` would have stopped immediately?

launch { var i = 0 while (i < 1_000_000_000) { i++ } println("done") }