Using Worker Threads
Learn how to use worker threads to solve issues that arise with CPU-bound tasks.
We'll cover the following...
Since Node 10.5.0, we have a new mechanism for running CPU-intensive algorithms outside of the main event loop called worker threads. Worker threads can be seen as a lightweight alternative to child_process.fork()
with some extra advantages. Compared to processes, worker threads have a smaller memory footprint and a faster startup time since they run within the main process but inside different threads.
Even though worker threads are based on real threads, they don’t allow the deep synchronization and sharing capabilities supported by other languages such as Java or Python. This is because JavaScript is a single-threaded language and it doesn’t have any built-in mechanism to synchronize access to variables from multiple ...