what is the use case/purpose of this?
# coroutines
r
what is the use case/purpose of this?
t
The idea is to introduce a
ThreadLocal
variable to be shared between coroutines. This variable can be read from a running coroutine with
coroutineContext
.
r
ok so do I understand correctly it is a way to share data between threads when using coroutines?
t
Coroutines offer an abstraction over using threads. They focus more on communicating between coroutines than sharing state between them. The main primitive to communicate between coroutines are `Channel`s : https://kotlinlang.org/docs/reference/coroutines/shared-mutable-state-and-concurrency.html