4 ms·
The difference is that Go has what looks like preemptive scheduling for goroutines (and will eventually be truly preemptive; see [1]) while await is more like c
by skybrian 13y ago
The difference is that Go has what looks like preemptive scheduling for goroutines (and will eventually be truly preemptive; see [1]) while await is more like cooperative multitasking. If you're writing in Go, you should use channels (or mutexes) to avoid race conditions: "share by communicating".
With a single-threaded language using await, it's safer to modify common data structures without locks, although you should be aware that calling a function via "await" gives others task the opportunity to modify your data. So "await" appearing in the code explicitly warns you that pseudo-multitasking is happening. In Go, preemption can (in theory) happen at any time, plus there are multiple threads.
[1] http://honnef.co/posts/2013/08/what_s_happening_in_go_tip__2013_08_15_/ http://honnef.co/posts/2013/08/what_s_happening_in_go_tip__2...
Edit: Go isn't truly preemptive in 1.1.