Sanket Mehta
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.async import kotlinx.coroutines.runBlocking import java.util.stream.IntStream fun main() { runBlocking { val asyncs = IntStream.range(0, 6).mapToObj { GlobalScope.async { handleData("handler-$it") } } asyncs.forEach { runBlocking { it.await() } } } } private fun handleData(handlerName: String) { println(handlerName) while (true) { } }
Andrzej
fun main() { runBlocking { val asyncs = IntStream.range(0, 6).mapToObj { GlobalScope.async { handleData("handler-$it") } }.toList() asyncs.awaitAll() } }
Kroppeb
A modern programming language that makes developers happier.