The previous example used send() to put items into the Channel. offer() also puts items into the Channel. The difference is:

  • send() blocks until it can put its item into the Channel

  • offer() tries to put its item into the Channel and gives up if it cannot, quietly failing (i.e., no exception)

So, in this snippet, we have a hot channel: we are using offer() to try to deliver values, but gracefully failing if nothing is in position to receive those values. Since we are now delaying our consumeEach() call by a second, we will miss some of the offered items. We ask for 10 and we wind up getting 6 or so.

You can learn more about this in:
Run Edit