You are previewing The Go Programming Language Phrasebook.

The Go Programming Language Phrasebook

Cover of The Go Programming Language Phrasebook by David Chisnall Published by Addison-Wesley Professional
O'Reilly logo

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 ...

The best content for your career. Discover unlimited learning on demand for around $1/day.