Node.js
/Advanced
Thread Pool
Definition
A collection of background threads maintained by `libuv` to execute heavy tasks that cannot be handled asynchronously by the OS kernel, preventing them from blocking the main Event Loop.
Explain Like I'm New
Wait, I thought Node was single-threaded? The JavaScript code YOU write is single-threaded. But deep in the basement, `libuv` maintains a secret team of 4 C++ workers (The Thread Pool). When you ask Node to hash a password or read a file, it secretly passes that work to the basement workers. They do the heavy lifting simultaneously while your main thread keeps serving web pages.
Real World Example
Cryptographic functions (`pbkdf2`), File System operations (`fs.readFile`), and DNS lookups all use the Thread Pool automatically.
Common Use Cases
- •Optimizing CPU-bound internal operations
Interactive Example
Loading Code Playground...
Interview Questions
basic
- How many threads does the libuv Thread Pool have by default?
intermediate
- What happens if you run 5 heavy cryptography functions at the exact same time?