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

Rolbin

11/18/2020, 2:11 PM
Hello, I was reading about coroutines and I came across this in an SO answer. "when you execute 1,000,000 concurrent routines, it doesn't have to create 1,000,000 threads" Let's say, these many routines run on just 4 threads. In that case it's same as that of a fixed thread pool of size 4 ?
a

alex

11/18/2020, 2:18 PM
yes and no, because coroutines are more flexible than just task executor.
z

Zach Klippenstein (he/him) [MOD]

11/18/2020, 2:18 PM
That's a tautology, so yes 😉 By default, coroutines run on the
Default
dispatcher, which uses a thread pool of count roughly equal to the number of logical cores available (and a minimum of 2, I think, to avoid weird behavior on systems with only a single core).
r

Rolbin

11/18/2020, 2:24 PM
Thanks a lot 😊
3 Views