mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 21:46:48 +00:00

PR-URL: https://github.com/nodejs/node/pull/32549 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
15 lines
431 B
JavaScript
15 lines
431 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const path = require('path');
|
|
const assert = require('assert');
|
|
const { Worker, isMainThread, parentPort } = require('worker_threads');
|
|
|
|
if (isMainThread) {
|
|
const w = new Worker(`./${path.relative('.', __filename)}`);
|
|
w.on('message', common.mustCall((message) => {
|
|
assert.strictEqual(message, 'Hello, world!');
|
|
}));
|
|
} else {
|
|
parentPort.postMessage('Hello, world!');
|
|
}
|