MessageChannel
A pair of connected ports for sending messages between threads: what you post on one port arrives as a message event on the other.
In more detail
Messages are copied with the structured clone algorithm, except for memory explicitly transferred or shared. Browsers use the same API between windows and web workers.
Related terms
- structured clone algorithm — The standard JavaScript algorithm for deep-copying values between threads and into storage, which handles Maps, Sets, Dates, typed arrays and circular references.
- worker threads — The Node.js module for running JavaScript in parallel threads inside one process, each with its own V8 isolate and event loop.
- SharedArrayBuffer — A block of raw memory that several threads can read and write at the same time, without copying.
Taught in
- Worker Threads: worker_threads & SharedArrayBuffer — Node.js Internals & Backend Services
- Thread Pooling: Piscina & CPU-Bound Workload Pools — Node.js Internals & Backend Services