Concurrency Patterns
Part of the Go course
Goroutines and channels are raw materials, like wood and screws. Knowing what they are does not tell you how to build a chair. In practice, almost all concurrent Go code is assembled from a handful of recognisable shapes, and once you can name them you will see them in every real codebase you open, doing the same job each time.
This lesson covers five of those shapes. Waiting on whichever of several things happens first. Telling work to stop before it finishes. Waiting for a group of goroutines to be done. Protecting a value that two goroutines both write to. And handing a big pile of jobs to a fixed team of workers instead of hiring one worker per job.
Want to learn Go Concurrency Patterns in a real environment?
Click below, get a fresh Linux box with Go ready to go, and work through Concurrency Patterns hands-on with an AI tutor that knows your code.
Start this lessonConcurrency PatternsWhat you'll learn
- Select statement
- Context.Context for cancellation
- Sync.WaitGroup
- Sync.Mutex
- Worker pool pattern
- Fan-out fan-in idea
