Go scheduler
The part of the Go runtime that decides which goroutine runs on which operating system thread, and when.
In more detail
It switches between goroutines when they block, for example on a channel or a network call. Its order is not guaranteed, so never write code that depends on which goroutine runs first. Sort results afterwards if a report needs a stable order.
Related terms
- goroutine — A function running concurrently with the rest of a Go program, started by putting the go keyword before a call.
- Go runtime — The support code the compiler builds into every Go program, which schedules goroutines, manages memory and collects garbage.
- thread — A path of execution inside a process that the operating system schedules on a processor; one process can have many.
Taught in
- Goroutines and Concurrent Execution — Concurrent Systems Programming with Go