Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What kind of multithreading does emscripten support?


Asked by Marcelo Conway on Dec 08, 2021 FAQ



Emscripten has support for multithreading using SharedArrayBuffer in browsers. That API allows sharing memory between the main thread and web workers as well as atomic operations for synchronization, which enables Emscripten to implement support for the Pthreads (POSIX threads) API. This support is considered stable in Emscripten.
Keeping this in consideration,
The main browser thread is where web pages start to run JavaScript, and where JavaScript can access the DOM (a page can also create a Web Worker, which would no longer be on the main thread). The main application thread is the one on which you started up the application (by loading the main JS file emitted by Emscripten).
Consequently, The Emscripten pthreads documentation contains relevant documentation for multithreading. Threads are supported in some (but not all) browsers. Configuration changes may be required. The [1] demo can be used to determine if thread support is available.
Indeed,
For more information click this Emscripten has support for multithreading using SharedArrayBuffer in browsers. That API allows sharing memory between the main thread and web workers as well as atomic operations for synchronization, which enables Emscripten to implement support for the Pthreads (POSIX threads) API.
And,
Emscripten converts OpenGL into WebGL, and has support for familiar APIs like SDL, pthreads, and POSIX, as well as Web APIs and JavaScript.