Search⌘ K
AI Features

Goroutines

Explore how goroutines function as lightweight threads in Go, allowing multiple functions to run concurrently. Learn the basics of starting goroutines, managing shared memory, and understanding concurrency through practical examples in this lesson.

We'll cover the following...

Definition

A goroutine is a lightweight thread managed by the Go runtime. Goroutines can be functions or methods that run concurrently with other functions or methods

Go (1.6.2)
go f(x, y, z)

starts a new goroutine running:

Go (1.6.2)
f(x, y, z)

The evaluation of f, x, y ...