• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const path = require('path');
4const assert = require('assert');
5const { Worker, isMainThread, parentPort } = require('worker_threads');
6
7if (isMainThread) {
8  const cwdName = path.relative('../', '.');
9  const relativePath = path.relative('.', __filename);
10  const w = new Worker(path.join('..', cwdName, relativePath));
11  w.on('message', common.mustCall((message) => {
12    assert.strictEqual(message, 'Hello, world!');
13  }));
14} else {
15  parentPort.postMessage('Hello, world!');
16}
17