Suspend Is Not Async: Why Kotlin suspend Doesn't Switch Threads
Understanding the difference between execution context and the permission to pause. There is a recurring “ghost” in Android and KMP production code: the Blocking Suspend Function . Most developers believe that marking a function with suspend magically teleports the execution to a background thread. This misunderstanding is the #1 cause of "mysterious" UI stutters in coroutine-based apps. To master coroutines, we must dismantle the myth and look at what the Kotlin compiler is actually doing under the hood. 1. The Visual Mental Model: Thread vs. Coroutine vs. Suspension To understand high-performance Kotlin, you must differentiate between the Worker , the Task , and the Pause . Thread (The Worker): An OS-level resource. Expensive to create (~1MB stack) and expensive to switch. Coroutine (The Task): A lightweight unit of work scheduled by a dispatcher. You can have thousands (even millions, memory permitting) because they are just objec...