Worker Threads

Node.js worker_threads module — threading support.

Beyond this IDL surface, the enriched module also provides: MessagePort, MessageChannel, BroadcastChannel, receiveMessageOnPort, moveMessagePortToContext, markAsUncloneable, markAsUntransferable, isMarkedAsUntransferable, setEnvironmentData, getEnvironmentData, postMessageToThread, resourceLimits, threadName, SHARE_ENV, and locks (Web Locks API).

Workers support CJS require, ESM with top-level await, nested workers, eval mode, transferable ArrayBuffers, and structured cloning.

Module: node:worker_threads Support: Experimental Since: 1.1.0 Docs: Node.js Docs See also: https://nodejs.org/api/worker_threads.html

5 members: 5 undocumented

Properties

⚪ isMainThread
True if this code is running inside a Worker thread.
⚪ parentPort
A reference to the parent port if running inside a Worker, null otherwise.
⚪ threadId
An integer identifier for the current thread.
⚪ workerData
A clone of data passed to this Worker's constructor.
⚪ Worker
The Worker class constructor.