7 ms·
I'm puzzled, what's the use case for threads in the node asynchronous model ? Isn't the major use of threads is to prevent long running task from blocking the a
by cedias 13y ago
I'm puzzled, what's the use case for threads in the node asynchronous model ? Isn't the major use of threads is to prevent long running task from blocking the app in synchronous programming ?
- rpedela 13y agoSometimes you need to do a lot of CPU work which the async I/O model will never help with.
- szx 13y agoCPU-bound loads still block the event loop. Modules take care of this behind the scenes (sometimes?) but if you're rolling your own expensive operation threads can come in handy.
- scubaguy 13y agoIO is asynchronous, but code execution is not asynchronous. If a block of code is doing intensive math for 100ms, then that blocks the whole process, and potentially other IO, from executing in that 100ms. Perhaps you should think of node as "event-driven" rather than "asynchronous".