node.js - Grasping the Node JS alternative to multithreading -


if understand correctly node js non blocking...so instead of waiting response database or other process moved on else , checks later.

also single threaded.

so mean given node js process can , efficiently utilize single cpu core not use other core on machine, in, never use more 1 @ time.

this of course means other cpus can still used other processes things sql database or other intentionally separated cpu heavy subroutines long separate process.

also in event node js process has endless loop or long running function, process no longer useful in way until endless loop or long running function stopped (or whole process killed).

is right? correct in understanding?

pretty correct, yes. node.js server has internal thread pool can perform blocking operations , notify main thread callback or event when things complete.

so imagine make limited use of core thread pool, example if non-blocking file system read implemented telling thread thread pool perform read , set callback when it's done means read happening on different thread/core while main node.js program doing else.

but node.js point of view, it's entirely single threaded , won't directly use more 1 core.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -