Re:How JavaScript works: Event loop and the rise of Async pr...
by anoopelias on Saturday October 14, 2017 @04:03PM
(#15473947)
> Does this mean that a web server written in node is running single-threaded?
JavaScript is single threaded. Node.js is not.
Node executes the entire JavaScript code in a single thread. However, the I/O requests dispatched by the JavaScript code (file I/O, network I/O, db I/O) can be executed in separate threads.
That is why Node is efficient for applications with lot of I/O (typical web apps), and can still provide a default thread safety for global objects.
But I think, it will not work efficiently for number-crunching CPU intensive applications.
JavaScript is single threaded. Node.js is not.
Node executes the entire JavaScript code in a single thread. However, the I/O requests dispatched by the JavaScript code (file I/O, network I/O, db I/O) can be executed in separate threads.
That is why Node is efficient for applications with lot of I/O (typical web apps), and can still provide a default thread safety for global objects.
But I think, it will not work efficiently for number-crunching CPU intensive applications.