https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

Simon Lin

01/29/2021, 3:34 AM
According to the Dispatchers.IO doc:
... using withContext(Dispatchers.IO) { ... } does not lead to an actual switching to another thread — typically execution continues in the same thread.
So how does it do not to blocking thread but using same thread? When does it really switch another thread? (or never?) --- Edit: The key is
Thread pool
?
👀 1
b

bezrukov

01/29/2021, 7:11 AM
Default and IO dispatchers are using common thread pool. If you will switch from Default to IO it will mark current thread as io (and if there are coroutines waiting for Default dispatcher, it will spawn one more thread)
3
2 Views