7 ms·
Node has worker threads, which are basically the equivalent of Web Workers from browsers, with similar message based API
by infensus 5y ago
Node has worker threads, which are basically the equivalent of Web Workers from browsers, with similar message based API
- matheusmoreira 5y agoWow really? Since when/what version? I have to see it. How did they solve the serialization issue? If I remember correctly that was necessary to pass objects between threads.
- infensus 5y agoI think they became stable in v12. I'm actually not sure about the internal implementation, but from user's point of view you can pass almost [1] any value via a message and you will get a copy on the other side. You can even share memory between threads with SharedArrayBuffer. [1] https://nodejs.org/api/worker_threads.html#worker_threads_port_postmessage_value_transferlist https://nodejs.org/api/worker_threads.html#worker_threads_po...