Commit | Line | Data |
---|---|---|
1 | const { | |
2 | isMainThread, | |
3 | parentPort | |
4 | } = require('worker_threads') | |
5 | ||
6 | if (!isMainThread) { | |
7 | for (let i = 0; i <= 1000; i++) { | |
8 | const o = { | |
9 | a: i | |
10 | } | |
11 | JSON.stringify(o) | |
12 | } | |
13 | // console.log('This is the main thread ' + isMainThread) | |
14 | parentPort.postMessage({ ok: 1 }) | |
15 | } |