Skip to content

Commit d507478

Browse files
committed
Add comment
1 parent 2cfaed9 commit d507478

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

JavaScript/7-binary-safe.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ if (isMainThread) {
4343
const semaphore = new BinarySemaphore(workerData);
4444
const array = new Int8Array(workerData, 4);
4545
const value = threadId === 1 ? 1 : -1;
46+
4647
setInterval(() => {
4748
semaphore.enter();
4849
for (let i = 0; i < 10; i++) {
4950
array[i] += value;
5051
}
5152
console.dir([ threadId, semaphore.lock[0], array ]);
5253
semaphore.leave();
53-
}, 100);
54+
}, 100); // change to 10 to see race condition
5455
}

0 commit comments

Comments
 (0)