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

A goroutine is spinning in this loop. On Go 1.13 vs Go 1.14+, what is the difference in whether the runtime can preempt it for a STW (stop-the-world) GC phase, assuming GOMAXPROCS=1 and another goroutine wants to run?

func busy() { x := 0 for i := 0; i < 1_000_000_000; i++ { x += i } _ = x } func main() { runtime.GOMAXPROCS(1) go busy() runtime.GC() // wants a STW phase }