How does node.js implement non-blocking I/O?
javascript, node.js, nonblocking
Solution
It is true that operations such as sleep will be blocking the thread. But I/O events can indeed be asynchronous.
Node.js uses an event loop for this. An event loop is “an entity that handles and processes external events and converts them into callback invocations”
Whenever data is needed nodejs registers a callback and sends the operation to this event loop. Whenever the data is available the callback is called.
http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/ for more info
Problem
From here i have found that `node.js` implements non-blocking i/o model. But i don't understand how. As javascript is single threaded. How can a single thread do i/o operations and simultaneously executing the further process.