You could use the following method.
const { Worker, isMainThread, parentPort, workerData } = require(‘worker_threads’);