Apparently if we call channel.receive()
against an empty channel, it suspends, which is exactly as documented here in official docs. Is there a way to immediately return a null
instead, like what ConcurrentLinkedQueue
's poll()
does?
CodePudding user response:
Yes, we can use tryReceive():
channel.tryReceive().getOrNull()