Sobes.tech
Middle+

If you create a goroutine, does the scheduler immediately execute it?

sobes.tech AI

Answer from AI

No, the scheduler does not execute a goroutine immediately after its creation. When go is called to start a goroutine, it is placed in the scheduler's queue. The Go scheduler manages the execution of goroutines by distributing them across available system threads (M) and processors (P). A goroutine can be started almost immediately, but this depends on the current load and the scheduler's state. Therefore, creating a goroutine is an asynchronous operation, and its execution begins at the earliest available opportunity, but not instantly.

If you create a goroutine, does the scheduler… - sobes.tech