Lesson 37 of 38 · Concurrency
Quiz: Go Concurrency
Goroutines make concurrency cheap in Go; the rest of this chapter was about coordinating them. sync.WaitGroup waits for goroutines to finish, channels hand over values and synchronise the sender with the receiver, close and range end a stream of values, select waits on several channel operations at once — with timeouts and non-blocking default cases — and a sync.Mutex protects state that many goroutines share.
Answer these six questions, then face the last boss of the Gopher Isles.
What this quiz covers
The questions check what you learned in the Concurrency chapter of Learn Go. Not sure about a topic? Review its lesson first:
- Goroutines in Go: Lightweight Concurrency
Run functions concurrently with the go keyword, wait for goroutines with sync.WaitGroup and collect results safely. Concurrency vs parallelism in Go.
- Go Channels: Communicating Between Goroutines
Send values between goroutines with Go channels: make(chan T), send and receive, unbuffered channels, deadlocks and directional types like chan<- int.
- Go Buffered Channels, close and range
Use buffered channels in Go, close a channel to signal the end of the data, receive with range and the comma-ok idiom, and build generators and pipelines.
- Go select: Timeouts and Non-blocking Channels
Wait on several Go channels at once with select, add timeouts with time.After, use default for non-blocking receives and stop loops with a done channel.
- Go Mutex: Protecting Shared State with sync.Mutex
Avoid data races in Go: protect shared variables and maps with sync.Mutex and RWMutex, count with sync/atomic and learn when to use channels instead.
Keep learning
Need a quick reminder? The Go cheat sheet has every topic of Learn Go on one page.
Lesson last updated on .