I understand it correctly

f I understand it correctly the “WASM standard” does not support/define os threads? So how are gorutines multiplexed in the runtime? Are there some limitation that I need to consider?

Can the runtime handle two gorutines in a tight loop?

WebAssembly (so far) allows only one thread of execution. However, that does not mean you can’t have goroutines because goroutines are not threads. :slight_smile:

The way goroutines work is to supply concurrency, not necessarily parallelism. There can be many goroutines executing in each thread, and even if there is only a single thread, there can still be many goroutines.

So the limitation with WebAssembly (at this time), is that it is not possible for Go to use more than one of the CPU’s cores. That will probably change as WebAssembly is developed more.

This talk by Rob Pike explains parallelism vs. concurrency, and how concurrency works in Go: https://www.youtube.com/watch?v=cN_DpYBzKso

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.