Structure concurrent work with Kotlin coroutines

8 steps · about 4 h · Intermediate

  1. Launch coroutines inside a scope (guide, JetBrains (Kotlin docs), 30 min)

    Structured concurrency is the rule every later step depends on: work lives and dies with its scope.

  2. Run suspending calls in sequence or parallel (guide, JetBrains (Kotlin docs), 25 min)

    async and await show when concurrency actually saves time and when it only adds risk.

  3. Choose the right dispatcher (guide, JetBrains (Kotlin docs), 30 min)

    Knowing which thread pool runs your code prevents blocked UI threads and starved I/O.

  4. Cancel work cooperatively (guide, JetBrains (Kotlin docs), 25 min)

    Cancellation only works if your code checks for it; learn how to make long loops respond.

  5. Contain failures with supervisors (guide, JetBrains (Kotlin docs), 30 min)

    See how one failing child can cancel its siblings and how supervisor scopes stop that.

  6. Stream values with Flow (guide, JetBrains (Kotlin docs), 45 min)

    Cold flows model sequences of async values with familiar operators and built-in back-pressure.

  7. Pass values between coroutines with channels (guide, JetBrains (Kotlin docs), 30 min)

    Channels cover the hot, producer-consumer cases that Flow does not.

  8. Guard shared state against races (guide, JetBrains (Kotlin docs), 25 min)

    Finish with mutexes, confinement and atomics so concurrent code stays correct.