Node.js introduced the worker-threads module, which allows you to create threads and execute multiple JavaScript tasks in parallel.
Once a thread finishes a task, it sends a message to the main thread that contains the result of the operation so that it can be used with other parts of the code.
The advantage of using worker threads is that CPU-bound tasks don’t block the main thread and you can divide and distribute a task to multiple workers to optimize it.