Challenge: Demonstrate the Blocking Nature

This lesson brings you a challenge to solve.

We'll cover the following

Problem statement

Demonstrate the blocking nature of channels by making a channel and starting a goroutine that receives the value from the channel but after waiting for 5s. Then, put a value (of your own choice) on the channel. Print messages at the different stages and observe the output.

Output

sending
received
sent

The messages sending, received, and sent are printed at different stages.

Hint: Don’t forget to import time.

Try to attempt the challenge below. Good Luck!

Get hands-on with 1400+ tech skills courses.