3 ms·
How come? How are goroutines different from real threads such that they're easier to reason about?
by twic 6y ago
How come? How are goroutines different from real threads such that they're easier to reason about?
- matklad 6y agoIn theory, they are equivalent. In practice, POSIX blocking IO does create problems around cancellation and selectability. For example, there’s no good way to cancel an outstanding blocking read call, and you might need to do weird hops to work around that. If you do goroutines, you need to redo all IO yourself anyway, and that’s a good opportunity to implement things like universal support for cancellation and timeouts.