Has Node.js Abstarcted that multithreading?

Hey Guys , I am new to Node.js and have a doubt to clear ...

My question is when node js is single threaded and non blocking tel me about this scenario. Like When client1 sends a request to get the data from DB to the main thread of Node , Node assigns the task to the thread pool and say the T1 thread from the thread pool will be executing that task by accessing the data from DB.... Lets at the same time another client say client2 requests some data from DB to the main thread and node assigns that task also to the thread pool so say T2 also goes to the same DB to get the data but still T1 has not finished accessing data from DB .. So T2 is basically WAITING right ? N guys also share some good videos and documents on Node.js and basic programming examples..

Thanks


There is no thread pool in JavaScript. Why would you expect one in a NodeJS environment, which is little more than V8?

Concurrency (not multithreading) is done by way of an event loop, not threads. In your example, if you do not have a connection pool to your DB, yes, T2 will wait for T1 to be finished with the DB connection . There is still no element of threading, the limit is that your DB connection can most likely not be multiplexing queries.

链接地址: http://www.djcxy.com/p/52528.html

上一篇: 在Web应用程序上执行压力测试?

下一篇: Node.js是否突破了多线程?