Programming Languages Go Subjective
Oct 04, 2025

Explain goroutines and how they differ from threads.

Detailed Explanation
Goroutines vs Threads: • Goroutines are lightweight (2KB initial stack vs 2MB for threads) • Managed by Go runtime, not OS • Multiplexed onto OS threads (M:N model) • Cooperative scheduling vs preemptive • Communication via channels, not shared memory • Much cheaper to create and destroy • Can have millions of goroutines Example: go func() { fmt.Println("Hello from goroutine") }()
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback