July 2018
Intermediate to advanced
266 pages
7h 11m
English
The first one would be to check the property isClosedForReceive, which indicates whether or not the channel has been closed for receiving, as the following for example:
val channel = Channel<Int>()channel.isClosedForReceive // falsechannel.close()channel.isClosedForReceive // true
If receive is called in a channel that is closed, a ClosedReceiveChannelException will be thrown:
val channel = Channel<Int>()channel.close()channel.receive()
This code will simply crash:

Read now
Unlock full access