Blogs / What It Means for a Goroutine to Block

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.

  • Learning
  • 1 min read

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]

GoroutineConcurrencyprimitiveschannels, locks and waitgroupsOperating systemoperationsnetwork sockets or filesblocks onblocks on
What can a goroutine block on, according to the post?

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

  1. Goroutine Leak Profiles (go.dev · checked )

More articles