by gregors · 3y ago · 0 comments
package main
import (
"fmt"
"runtime"
)
func infiniteLoop() {
for {}
fmt.Println("world")
}
func main() {
runtime.GOMAXPROCS(1)
go infiniteLoop()
fmt.Println("hello")
}
For more information, see Go's source code which is exceptionally well commented:
https://go.dev/src/runtime/preempt.go