10. Concurrency Design Patterns

In Chapter 9, Goroutines, we looked at a number of ways of synchronizing activities between goroutines, using patterns that are common in other languages. As with other facets of the language, there are some idioms that are natural in Go, but which would not make sense in another language.

Concurrency is a core part of Go. Spawning a new goroutine, which is roughly analogous to a thread, requires you to type three characters, including the space. The implementation of these goroutines in gc is similarly lightweight—slightly more than a function call but not much. In gccgo, it is equivalent to an operating system thread.

In the last chapter, we saw that Go has more or less the same set of synchronization primitives ...

Get The Go Programming Language Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.