June 2018
Intermediate to advanced
310 pages
6h 32m
English
Now we'll have two types of workers:
fun divide(input: ReceiveChannel<List<Int>>, output: SendChannel<Int>) = async { var max = 0 for (list in input) { for (i in list) { if (i > max) { max = i output.send(max) } } }}
fun collector() = actor<Int> { var max = 0 for (i in this) { max = Math.max(max, i) } println(max)}
Now we only need to establish those channels:
val input = Channel<List<Int>>()val output = collector()val dividers = List(10) { divide(input
Read now
Unlock full access