Goroutines vs threads
Fast recall
Quick revision
Core answer
Concurrency fundamentals and runtime scheduling.
Assuming goroutines remove data races or always make code faster.
Mention structured cancellation with context and a wait mechanism such as sync.WaitGroup.
Interview-ready guide
Interview answer
A goroutine is a lightweight function scheduled by the Go runtime across OS threads. It makes concurrency inexpensive, but I still design ownership, cancellation, and synchronization explicitly because goroutines do not prevent races by themselves.
Goroutines vs threads
Direct Answer
A goroutine is a lightweight concurrent function managed by the Go runtime. The runtime multiplexes many goroutines over a smaller pool of OS threads, so they start cheaply, but shared data still needs synchronization.
Deep Dive & Architecture
A goroutine is a lightweight concurrent function managed by the Go runtime.
The runtime multiplexes many goroutines over a smaller pool of OS threads, so they start cheaply, but shared data still needs synchronization.
Starting a goroutine with go schedules a function independently. Channels can coordinate ownership of values; mutexes protect shared state when sharing is intentional.
A common mistake is assuming goroutines remove data races or always make code faster.
Code Example
var wg sync.WaitGroup
wg.Add(1)
go func() { defer wg.Done(); work() }()
wg.Wait()
Common Mistakes & Pitfalls
Assuming goroutines remove data races or always make code faster.
Check your understanding
Answer these without looking back at the article.
- When would you use Goroutine Basics in a real project?
- How would you compare Goroutine Basics with an alternative?
- What is a common mistake when using Goroutine Basics?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.