gotoOla
06/17/2019, 3:18 PMelizarov
06/17/2019, 3:21 PMgotoOla
06/17/2019, 3:28 PMelizarov
06/17/2019, 3:31 PMgotoOla
06/17/2019, 3:33 PMsuspend fun main() {
val channel = Channel<Job>(5)
GlobalScope.launch {
while(true) {
channel.send(doJob(System.currentTimeMillis()))
}
}
for(job in channel) {
job.join()
}
}
private fun doJob(time: Long): Job {
return GlobalScope.launch {
println("starting a job and waiting")
delay(5000)
}
}
But I see the logs come in bursts of 7 even though the capacity is 5. Did I missunderstand something here?elizarov
06/17/2019, 8:49 PMgotoOla
06/17/2019, 8:55 PM