You create a SharedArrayBuffer-backed Int32Array shared with a worker. The worker increments the value but the main thread sometimes reads a stale value. What is the correct fix?
const shared = new Int32Array(new SharedArrayBuffer(4));
// passed to worker via postMessage
// worker: shared[0]++ (many times)
// main: reads shared[0]