Skip to content

Commit 0113a12

Browse files
committed
Change comments
1 parent 14e5451 commit 0113a12

5 files changed

Lines changed: 6 additions & 4 deletions

File tree

JavaScript/1-shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ if (isMainThread) {
1616
array[i] += value;
1717
}
1818
console.dir([ threadId, array ]);
19-
}, 100);
19+
}, 100); // change to 10 to see race condition
2020
}

JavaScript/2-binary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ if (isMainThread) {
4545
}
4646
console.dir([ threadId, array ]);
4747
semaphore.leave();
48-
}, 100);
48+
}, 100); // change to 10 to see race condition
4949
}

JavaScript/3-counting.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CountingSemaphore {
2626

2727
if (isMainThread) {
2828
const buffer = new SharedArrayBuffer(4);
29-
// Try change 10 at next lene to 2 for example
29+
// Try change 10 to 2 at next lene to see problem
3030
const semaphore = new CountingSemaphore(buffer, 0, 10);
3131
console.dir({ semaphore: semaphore.counter[0] });
3232
for (let i = 0; i < 20; i++) {

JavaScript/4-callback.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class CountingSemaphore {
3636

3737
if (isMainThread) {
3838
const buffer = new SharedArrayBuffer(4);
39+
// Try change 10 to 2 at next lene to check solution
3940
const semaphore = new CountingSemaphore(buffer, 0, 10);
4041
console.dir({ semaphore: semaphore.counter[0] });
4142
for (let i = 0; i < 20; i++) {

JavaScript/5-atomics.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class CountingSemaphore {
2828

2929
if (isMainThread) {
3030
const buffer = new SharedArrayBuffer(4);
31-
const semaphore = new CountingSemaphore(buffer, 0, 2);
31+
// Try change 10 to 2 at next lene to check solution
32+
const semaphore = new CountingSemaphore(buffer, 0, 10);
3233
console.dir({ semaphore: semaphore.counter[0] });
3334
for (let i = 0; i < 20; i++) {
3435
new Worker(__filename, { workerData: buffer });

0 commit comments

Comments
 (0)