0
点赞
收藏
分享

微信扫一扫

Koltin actor


@Test
fun `test fast consumer channel`() = runBlocking<Unit> {
val sendChannel: SendChannel<Int> = GlobalScope.actor<Int> {
while (true) {
val element = receive()
println(element)
}
}

val producer = GlobalScope.launch {
repeat(4) {
sendChannel.send(it)
}
}

producer.join()

}

Koltin actor_java

 

举报

相关推荐

0 条评论