How to Prevent Race Conditions in Kotlin Coroutines
Dave Leeds
0:00 / 0:00
How to Prevent Race Conditions in Kotlin Coroutines
7 832 просмотра · 9 месяцев назад
Dave Leeds
16,2 тыс. подписчиков
7 832 просмотра · 9 месяцев назад
Kotlin's coroutines don't automatically prevent race conditions - it's up to the developer to deal with them! The good news is that Kotlin gives us several tools to choose from, including atomics, confinement, mutexes, and more. In this video, we'll take a look at all of them, and when you might want to use each one.
📝 Corresponding article:
https://typealias.com/articles/preven...
🚀 Newsletter: https://newsletter.typealias.com/
🎉 Coroutines course: https://courses.typealias.com/coroutines
✨ New to Kotlin? Start your journey here: https://typealias.com/start/
🎞️ Chapters in this video
00:00 - Race Conditions in Coroutines
01:18 - Atomics
02:17 - StateFlow
03:03 - Mutex (Mutual Exclusion)
04:20 - Confinement with limitedParallelism
05:35 - Confinement with Actors
07:29 - Avoiding Shared Mutable State
08:17 - Summary of Options