Re:Go 1.2 Release Candidate 1 released
by ominous_prime on Friday September 20, 2013 @09:36AM
(#6417589)
while they have added some preemption to the scheduler, go is still generally cooperative multitasking. I believe function calls are also schedule points now. If you have a cpu-intensive loop you want to yield from at certain points, stick a runtime.GoSched in there. Having a busy-loop in your code is going to mess things up, and is usually a bug anyway.
> Having a busy-loop in your code is going to mess things up, and is usually a bug anyway.
A busy loop is a sufficient way to emulate a heavy computation (e.g. applying effects to image files or compressing data) when it's not optimized out.
That will still block forever. If you include a function call in the loop though, it won't.
Does this still block forever?
package main
import "time"
func main() { go func(){ for {} }() time.Sleep(time.Millisecond) }