GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Semaphore/JavaScript/1-shared.js at master · HowProgrammingWorks/Semaphore

Expand file tree

/

1-shared.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
20 lines (18 loc) · 584 Bytes
/

1-shared.js

Copy path

File metadata and controls

20 lines (18 loc) · 584 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict';
const threads = require('node:worker_threads');
const { Worker, isMainThread } = threads;
if (isMainThread) {
const buffer = new SharedArrayBuffer(10);
new Worker(__filename, { workerData: buffer });
new Worker(__filename, { workerData: buffer });
} else {
const { threadId, workerData } = threads;
const array = new Int8Array(workerData);
const value = threadId === 1 ? 1 : -1;
setInterval(() => {
for (let i = 0; i < 10; i++) {
array[i] += value;
}
console.dir([ threadId, array ]);
}, 100); // change to 10 to see race condition
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.