Hey guys. I need to make parallel `flatMap` in Kot...
# announcements
б
Hey guys. I need to make parallel
flatMap
in Kotlin. How to do that ? For example:
Copy code
val coll: List<Set<Int>> = ...
coll.flatMap{set -> setOf(set, set + 1)}
g
Parallel? Kotlin doesn’t provide any threading out of the box
б
I’m allowed to use coroutines
g
Yes, you can use coroutines
I will send an example of such code
б
Thanks.
You need something like this
б
Thanks that’s what I needed.
@gildor One more question if you don’t mind. I tested the code and it closes threads and not finishes execution, because threads are closed (showing as ‘park’ state in VisualVM) and async can’t start new coroutines.
g
@Бежан Александр Which dispatcher do you use? Is your code is blocking? My code should works properly with new dispatchers, but with old one it depends on what operation does You can use new IO dispatcher if your operation is blocking (just add IO as argument of async)
👍 1