Skip to main content
Worker.prototype.postMessageToThread - worker_threads - Node documentation
method Worker.prototype.postMessageToThread

Usage in Deno

import { Worker } from "node:worker_threads";
Worker.prototype.postMessageToThread(
threadId: number,
value: any,
timeout?: number,
): Promise<void>

Sends a value to another worker, identified by its thread ID.

Parameters

threadId: number

The target thread ID. If the thread ID is invalid, a ERR_WORKER_MESSAGING_FAILED error will be thrown. If the target thread ID is the current thread ID, a ERR_WORKER_MESSAGING_SAME_THREAD error will be thrown.

value: any

The value to send.

optional
timeout: number

Time to wait for the message to be delivered in milliseconds. By default it's undefined, which means wait forever. If the operation times out, a ERR_WORKER_MESSAGING_TIMEOUT error is thrown.

Return Type

Promise<void>
Worker.prototype.postMessageToThread(
threadId: number,
value: any,
transferList: readonly TransferListItem[],
timeout?: number,
): Promise<void>

Parameters

threadId: number
value: any
transferList: readonly TransferListItem[]
optional
timeout: number

Return Type

Promise<void>
Back to top