Multithreading in WebAssembly

As I understand it, the multithreading model for the WebAssembly virtual machine is still in a draft state, so there's not support for the standard primitive operations that are required to make traditional multithreading work. I assume you're using Emscripten for your C++ code, in which case Emscripten is using cooperative multitasking to simulate "real" threads. This, as you noted, only allows executing one thread at a time and requires threads to explicitly yield control in order for other threads to execute.

If you're targeting a Web platform, the general solution for multi-threading is Web workers. There have been some experiments in both C++ and Rust to use Web workers for true parallelism:

Most of these approaches require instantiating a new WebAssembly module for each worker, and the ability for the threads to communicate with each other is rather limited, but the threads do truly run in parallel.