Junior — Middle
Are all goroutines required to start simultaneously and in parallel by default?
sobes.tech AI
Answer from AI
No, not all goroutines are required to start simultaneously and in parallel by default. Goroutines are lightweight threads scheduled by the Go scheduler.
When you start multiple goroutines, they can execute sequentially or in parallel, depending on the number of available system threads (GOMAXPROCS) and the current load.
By default, if GOMAXPROCS is set to 1, goroutines will run concurrently but not in parallel — meaning the scheduler switches between them, but only one executes at a time.
To achieve true parallelism, you need to increase GOMAXPROCS (usually to the number of CPU cores). Then, multiple goroutines can run simultaneously on different cores.