top | item 6834762

(no title)

cedias | 12 years 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 ?

discuss

order

scubaguy|12 years ago

IO 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".

szx|12 years ago

CPU-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.

rpedela|12 years ago

Sometimes you need to do a lot of CPU work which the async I/O model will never help with.