The Go runtime manages goroutines above the operating-system thread level, providing a lightweight execution model that uses fewer resources than OS threads. section 2.3
Rather than mapping every goroutine directly to a kernel thread, it uses M:N threading: many goroutines are distributed across a set of kernel-level threads. This lets concurrent work use multiple processors when available. section 2.3.2
The runtime coordinates concurrent execution by:
- Maintaining queues of goroutines for kernel-level threads to execute. section 2.3.2
- Allowing multiple kernel-level threads to run on separate processor cores. section 2.3.2
- Keeping work moving when a goroutine blocks on I/O by creating or reusing another thread and redistributing work. section 2.3.2
Inspecting available parallelism
A small program can print runtime.NumCPU() and runtime.GOMAXPROCS(0). For example, it may report eight CPUs and a GOMAXPROCS value of eight. Calling GOMAXPROCS with a value below one reads the current setting without changing it. section 2.3.2
A figure showing user-level threads executing within a single kernel-level thread makes the runtime’s layered execution model concrete. section 2.3.2

