We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2cfaed9 commit d507478Copy full SHA for d507478
1 file changed
JavaScript/7-binary-safe.js
@@ -43,12 +43,13 @@ if (isMainThread) {
43
const semaphore = new BinarySemaphore(workerData);
44
const array = new Int8Array(workerData, 4);
45
const value = threadId === 1 ? 1 : -1;
46
+
47
setInterval(() => {
48
semaphore.enter();
49
for (let i = 0; i < 10; i++) {
50
array[i] += value;
51
}
52
console.dir([ threadId, semaphore.lock[0], array ]);
53
semaphore.leave();
- }, 100);
54
+ }, 100); // change to 10 to see race condition
55
0 commit comments