What It Means for a Goroutine to Block
What the Go team's post says goroutines synchronize on, what blocking means and the other ways a goroutine can block.
For: Learners new to Go concurrency.
How goroutines coordinate
Goroutines synchronize or exchange information via shared concurrency primitives, e.g., channels, locks, and wait groups.[1]
What blocking means
While communicating, goroutines often block on these primitives, as in, wait until some condition is met; ubiquitous examples include waiting to acquire a held mutex, or receive a message over a channel.[1]
Blocking on the operating system
Goroutines can also block on operating system operations, like reading from a network socket or a file.[1]
Sources
- Goroutine Leak Profiles (go.dev · checked )
More articles
- LearningWhat SIMD Stands For and Why Go Needed Assembly BeforeWhat the Go team's post says SIMD stands for, how its instructions operate on wide registers and what Go programmers had to do before.
- LearningWhat a Size Class Is, and Why 16 and 24 Bytes Are CommonWhat the Go team's post says a size class is, why some small sizes are the most common and what a Go programmer needs to do.
- LearningWhat JSON Is and How Long Go Has Supported ItWhat the Go team's post says JSON is, how long Go has supported it and the status of the new packages.