Challenge: Channel and Actors

Solve the challenge of creating a channel where producer is faster than consumer (receiver).

We'll cover the following

Problem

Write a program to make our producer fast and our receiver slow with unlimited capacity. The channel should accept all the elements and then let them be received one after another.

Restriction

The output will be available in the terminal.

Output

The output will be as follows; here, we will see a delay of 0.2 seconds after every sent statement and 1 second of delay after every receiving statement. This will be repeated three times. After sending it to the channel, we will see a delay of 0.6 seconds (1(0.2×2)=0.6)(1−(0.2\times 2)=0.6).

Sent to channel
Sent to channel
Sent to channel
Received = 0
Received = 2
Received = 4

Get hands-on with 1200+ tech skills courses.