Go: Concurrent programming

This tutorial covers

Before you start, you need to know how to write basic Go programs. The resources in Go: Get started will help you come up to speed quickly with Go.

Start here

Table of contents

  1. Goroutines explained
    A goroutine is a lightweight thread of execution.
  2. Channels explained
    A channel is a mechanism for two goroutines to synchronize execution and communicate by passing values.
  3. Select explained
    A select statement allows you to wait for multiple send or receive operations simultaneously.
  4. Data races explained
    A data race is easily introduced by mistake and can lead to situations that are very hard to debug. This article explains how to avoid this headache.
  5. Detect data races
    By starting your application with the '-race' option, the Go runtime might be able to detect and inform you about data races.
  6. Deadlock
    The Go runtime can often detect when a program freezes because of a deadlock. This article explains how to debug and solve such issues.
  7. Wait for goroutines
    A sync.WaitGroup waits for a group of goroutines to finish.
  8. Broadcast a signal on a channel
    When you close a channel, all readers receive a zero value. This can be used to broadcast a signal to several goroutines on a single channel.
  9. Stop a goroutine
    A goroutine can stop only by returning from it's top level function. To make it stoppable, let it listen to a stop signal on a channel.
  10. Timer and Ticker explained
    Timers and Tickers are used to wait for, repeat, and cancel events in the future.
  11. Mutual exclusion lock (mutex)
    A sync.Mutex is used to synchronize data by explicit locking.
  12. Efficient parallel computation
    To efficiently schedule parallel computation on separate CPUs is more of an art than a science. This article gives some rules of thumb.