# node:worker_threads

> Worker threads, messaging, and the options Elide supports.

`node:worker_threads` runs scripts on separate threads; `elide run` does not exit while a worker is running.

## Exports

`Worker`, `isMainThread`, `isInternalThread`, `threadId`, `threadName`, `parentPort`, `workerData`,
`MessageChannel`, `MessagePort`, `BroadcastChannel`, `receiveMessageOnPort`, `postMessageToThread`,
`moveMessagePortToContext`, `getEnvironmentData`, `setEnvironmentData`, `markAsUntransferable`,
`isMarkedAsUntransferable`, `markAsUncloneable`, `getHeapSnapshot`, `SHARE_ENV`, and `resourceLimits`.

## Differences from Node

- `new Worker` reads only the `workerData`, `eval`, `transferList`, and `env` options.
- A missing script file emits `error` with code `ERR_WORKER_PATH`.
- `stdout` and `stderr` are always inherited from the parent.
- `resourceLimits` is `{}`.
- Posting a `ReadableStream` throws `DataCloneError`.
- Posting to a terminated worker is a no-op.
- `--limit=workers=COUNT` limits how many workers a script may start; see [Sandbox](https://elide.help/docs/sandbox).
