Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardGogoroutine preemptionSingle-choice MCQ

Before asynchronous preemption (pre-Go 1.14), this loop could hang the program on GOMAXPROCS=1. With async preemption, why does it now terminate?

package main import ( "fmt" "runtime" ) func main() { runtime.GOMAXPROCS(1) go func() { for { } }() runtime.Gosched() fmt.Println("reached") }