Hacker News new | ask | show | jobs
by brandonbloom 2409 days ago
Go creates the illusion of preemptive multithreading by having implicit safe-points for cooperative multithreading. Each IO operation is such a safe-point. If you write an infinite loop like `for {}` where there are no IO operations in loop body, it will block indefinitely. This will prevent the underlying OS thread from being available to other goroutines. The same thing can happen even if you do have IO operations in there, but the work being performed is dominated by CPU time instead of IO.
2 comments

Note that this is being fixed in the next release: https://golang.org/issue/10958
That's cool it's finally coming, this issue is open since 2015! I wonder which performance impact this will have.
Maybe this is a dumb question, but what if a language with implicit safepoints lets you opt out with something like a nosafepoint block/pragma?