I want to painlessly convert some java threads cod...
# coroutines
j
I want to painlessly convert some java threads code to kotlin coroutines. There is some code which creates as much threads as much as
Runtime.getRuntime().availableProcessors()
allows. Is there any common rule how much I should handle this situation in kotlin coroutines? Totally coroutines n00b here
g
You can just reuse Coroutines Default dispatcher, it also has pool of availableProcessors + 1 threads
1
One more way: create a thread executor and convert it to Coroutines dispatcher
But if you really want to migrate this code to Coroutines, I would Instead do that for code running inside of those thread, maybe you can optimize it and do not create so many thread and be non-blocking instead