Quoting David Finkel (2019-02-23 16:09:18) > Not only is fmt.Printf a function call, but it makes a blocking > syscall > (write specifically), > which gives the go runtime license to spin up a new OS thread and > immediately schedule the other goroutine. > runtime.GOMAXPROCS(1) only tries to guarantee that one OS thread > executing Go code will be executing at a time. > (this has no bearing on the revised version without a call to > fmt.Printf().)
Good point. This is also important because "pre-emption at function calls" is not entirely reliable, since a function call could possibly be in-lined or otherwise optimized in a way that mucks with things -- whereas blocking is going to be more reliable in this way. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.