Coroutine
Do not block the execution path while an endpoint waits on external services. Suspend the coroutine and let other work proceed.
Do not block the execution path while an endpoint waits on external services. Suspend the coroutine and let other work proceed.
Later work cannot use the I/O wait.
Problem and key mechanism: When a request synchronously holds its execution path while waiting for an external API, later work queues behind it; at each await, a coroutine preserves its progress, suspends, and yields execution, then resumes when the response arrives so other coroutines can use the I/O wait time.
Verify overlapping waits: With one slow response, other coroutines still advance and suspension is traceable. This does not prove CPU work runs in parallel.
Chat attachment uploads also suit coroutines: When a chat app uploads several attachments, each upload coroutine can suspend while waiting on the network. Other uploads continue and the suspended one resumes when its response arrives.
Run these three external API calls as coroutines that suspend during I/O, yield execution, then resume and combine results. Record suspension, resumption, and elapsed time. Add one slow response and verify other work is not blocked by synchronous waiting. Do not claim CPU-heavy work becomes faster automatically.