Concurrency doesn,t have to be hard: Kotlin Coroutines and Channels
summary
A concrete walkthrough shows Kotlin coroutines and channels replacing Thread.sleep and messy callbacks with suspend/delay, runBlocking, actors, produce, select and flows; a coffee‑shop system is built (cashier → channel → two baristas → shared espresso machine implemented with actors and completableDeferred) and measured: sequential version takes 12 seconds to 6 seconds with two baristas then ~5 seconds after async parallelism; use of completableDeferred and select solves routing, and closing the channel stops the deadlock.
AI-written summary · about
chapters (19)
- 0:00Start
- 1:06Futures
- 8:59Run Blocking
- 11:29Root Cause of the Problem
- 13:18Quarantine Scope
- 14:52How Channels Work
- 15:44Buffered Channel
- 16:14Conflated Channel
- 17:03Create an Orders Channel
- 22:19Recap
- 23:03New Espresso Machine Object
- 25:15Actor Quarantine Builder
- 26:27Select Keyword
- 27:11Select Statement
- 29:54Class Delegation
- 31:28Async Operator
- 32:46Flow
- 33:30Leverage Flows
- 34:56Flow Builder
related talks
40mConcurrency made easy with Kotlin Coroutines
33mVisualising concurrency with Kotlin
59mKotlin coroutines: new ways to do asynchronous programming
38mKotlin coroutines
28mConcurrency for Imposters
32m@Experimental Kotlin coroutines
49mKotlin Coroutines in Practice
42mKotlin Coroutines: An Intro to Practical Use on Android
