- Open your command-line application and navigate to your workspace.
- Create a new folder named 05-08-use-atomics-to-coordinate.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js file. Create three shared array buffers: an input buffer and two output buffers (one safe, the other unsafe). The output buffers should be 32 bits in size:
// main.jsconst NUMBER_COUNT = Math.pow(2, 10); const BYTES_FOR_32_BIT = 4;const ARRAY_SIZE = NUMBER_COUNT * BYTES_FOR_32_BIT; const sab = new SharedArrayBuffer(ARRAY_SIZE); const intBuffer = new Int32Array(sab); const outSab = new SharedArrayBuffer(BYTES_FOR_32_BIT); const unsafeSab = new SharedArrayBuffer(BYTES_FOR_32_BIT); const workerCount = 256; ...