MDN self-hosted library · e01.org

Atomics.waitAsync()

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
// Create a SharedArrayBuffer with a size in bytes
const sab = new SharedArrayBuffer(1024);
const int32 = new Int32Array(sab);
js
const result = Atomics.waitAsync(int32, 0, 0, 1000);
// { async: true, value: Promise {<pending>} }
js
Atomics.notify(int32, 0);
// { async: true, value: Promise {<fulfilled>: 'ok'} }