English
Summary
Conclusions
A coroutine separates a logical task from the thread that executes it. A structured scope defines the owner, cancellation defines the boundary of the work, and a dispatcher defines where it runs. Flow describes a sequence, and StateFlow the current state. Correctness starts with these contracts and only then moves on to choosing operators.
Self-check questions
- Does
suspendstart a new thread? - Why can
async { ... }.await()leave a program sequential? - When does
coroutineScopecomplete? - Why is cancellation called cooperative?
- Which errors does
catchhandle in a Flow? - Why is StateFlow unsuitable for a log of all transactions?