Grokking Concurrency in Go
0% completed
Who Owns a Channel
A team splits a page fetcher into two producer goroutines so that it finishes sooner. Each producer fetches its share of the URLs and sends the pages on one shared channel. The code that worked with one producer had a close at the end, so the copy for each producer has one too.
One possible output:
page from https://example.com/b page from https://example.com/a panic: send on closed channel goroutine 21 [running]: main.produce(...)
The first producer has one URL, so it sends one page after about 100 ms and closes the channel. The second producer has three URLs
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%