mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00

PR-URL: https://github.com/nodejs/node/pull/27650 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
17 lines
532 B
JavaScript
17 lines
532 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 cwdName = path.relative('../', '.');
|
|
const relativePath = path.relative('.', __filename);
|
|
const w = new Worker(path.join('..', cwdName, relativePath));
|
|
w.on('message', common.mustCall((message) => {
|
|
assert.strictEqual(message, 'Hello, world!');
|
|
}));
|
|
} else {
|
|
parentPort.postMessage('Hello, world!');
|
|
}
|