I want to really understand how threading works in...
# coroutines
t
I want to really understand how threading works in Android - like, what's actually happening under the hood when threads are created and managed. Then I want to dive deep into coroutines, not just how to use them but how they're actually built, why they were designed that way, and what's going on internally when they run. Looking for some solid resources that don't just skim the surface - maybe books, talks, or articles that actually explain the reasoning behind the design decisions and get into the nitty-gritty implementation details. Something that would help me truly get how all this stuff fits together rather than just learning the APIs.
y
this is likely very helpful: https://github.com/JetBrains/kotlin/blob/master/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/coroutines-codegen.md Also the KEEP I think Threading on Android is likely identical to the JVM, so I'd expect a JVM Threading tutorial to be helpful here. A key point to remember is that Coroutines are 2 pieces:
kotlin.coroutines
being the bare-bones primitives needed to support (delimited) continuations, and
kotlinx.coroutines
, which is a library that provides
Flow
,
CoroutineScope
,
Dispatcher
etc for structured concurrency and parallelism. Both these links are everything you'll practically need to understand the generated coroutines code and the rationale behind it and its design. There are some "historical" details that might be missing, such as the behaviour in past versions of Kotlin, but those are largely "fun facts" and likely won't affect understanding
t
Thank you @Youssef Shoaib [MOD] 🙌
m
Java Concurrency in Practice is an old book but still a great resource.
thank you color 1