Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavaScriptSharedArrayBuffer and AtomicsSingle-choice MCQ

Two threads share an Int32Array. Thread A does the store below, Thread B busy-reads index 1 with a plain load until it sees 42. Under the JS memory model, is B guaranteed to observe x === 1 once it sees the flag?

// Thread A: Atomics.store(shared, 0, 1); // x Atomics.store(shared, 1, 42); // flag // Thread B: while (shared[1] !== 42) {} // plain load on flag console.log(shared[0]); // plain load on x