# Threading in WASM *last updated: 2021-04-04* Experimental (but stable) support for `pthreads` using `SharedArrayBuffer`, `postMessage` and web workers * works in Firefox & Chrome but needs special headers * `Cross-Origin-Opener-Policy: same-origin`<br>`Cross-Origin-Embedder-Policy: require-corp` * `postMessage` latency ~0.5-1ms for structured clone (size dependent) * can be architected to setup worker pool at startup via compiler options * however the job distribution might still happen through structured clone * **emscripten** compiler toolchain implements `POSIX` threads with few caveats but mostly addressable. * can be useful if a multistage function/complex operation needs to be parallelized * no obvious higher order components/syntactic sugar to simplify job distribution and reduction/joining, * could still be faster because of LLVM compiled instructions. However for job distribution on batch level (and concurrency safe single threaded WASM function/operation), webworkers or nodejs workers (or `threads` package) can themselves be further optimized to reduce job distribution latency without going into WASM multithreading. --------------------------------------- PS: *this work has not been funded or granted by anyone. if you think this adds value to the ecosystem you could tip the author at: [0xb44ddd63d0e27bb3cd8046478b20c0465058ff04](https://etherscan.io/address/0xb44ddd63d0e27bb3cd8046478b20c0465058ff04)*