Skip to content
Senior221 views

For what types of requests do goroutines provide an advantage over OS threads, and for what types are OS threads equally effective?

Practice

Asked at

AI answer

Goroutines are especially advantageous when you need many concurrent tasks that spend much of their time waiting—for example, handling network requests, calling services, or performing other I/O. They are lightweight, and Go’s runtime multiplexes them over a smaller pool of OS threads. OS threads are equally effective for CPU-bound work when you need actual parallelism, and may be appropriate when interfacing with APIs that require a dedicated thread or when work blocks outside Go’s scheduler. The best choice depends on workload and runtime behavior; goroutines still execute on OS threads.