juniorGolang

What are Goroutines and how do they differ from OS threads?

Updated Apr 28, 2026

Short answer

Goroutines are lightweight, user-space threads managed by the Go runtime, not the OS.

Deep explanation

Unlike OS threads which have a large fixed stack (typically 1-2MB) and context-switching overhead managed by the kernel, Goroutines start with a tiny stack (2KB) that grows dynamically. The Go runtime multiplexes thousands of Goroutines onto a few OS threads using its own M:P:G scheduler, making concurrency extremely cheap.

Real-world example

Handling thousands of concurrent HTTP requests in a web server where each request is processed in its own goroutine without exhausting system memory.

Common mistakes

  • Assuming goroutines are completely free. While cheap, launching millions of them indefinitely will still cause OOM (Out Of Memory) errors.

Follow-up questions

  • How are Goroutines scheduled?

More Golang interview questions

View all →