blob: 47e497b07b5164de3bfeef61393294642f2c494a [file] [log] [blame] [edit]
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker, threadName, workerData } = require('worker_threads');
const name = 'test-worker-thread-name';
if (workerData?.isWorker) {
assert.strictEqual(threadName, name);
process.exit(0);
} else {
const w = new Worker(__filename, { name, workerData: { isWorker: true } });
assert.strictEqual(w.threadName, name);
w.on('exit', common.mustCall(() => {
assert.strictEqual(w.threadName, null);
}));
}