Grokking Concurrency in Go
Vote

0% completed

​

Signaling with Closed Channels

Output:

released before close: 0 released after close: [0 1 2 3 4 5 6 7 8 9]

Ten goroutines start, and each one waits at the same line, a receive on start. Nothing is ever sent on that channel, so after 50 ms none of those receives has completed, and the buffer of released is still empty. Then main calls close(start) once, and all ten receives complete. Each goroutine reports its id, and main prints all ten.

No value was sent, yet ten goroutines received something. The questions this page answers are why one `close

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content