Definition: node. js is a JavaScript running platform running on the server side using the Google V8 engine
Features: 1. asynchronous I/O (non-blocking I/O) 2. Event-driven
What is asynchronous I/O (non-blocking I/O)?
To understand what asynchronous I/O is (non-blocking I/O), you must first understand what I/O, what is blocking, and what is synchronous I/O (blocking I/O).
Definition of I/O: threads are collectively referred to as I/O operations when performing disk reads or writes or network traffic.
Blocking definition: In the process of I/O, the operating system deprives the thread of control of the CPU and causes the thread to suspend execution because it takes a long time to take. At the same time, the resources to other threads, such a scheduling method called blocking.
Blocking I/O: When the I/O operation is complete, the operating system relieves the blocking state of the thread, restores its control over the CPU, and lets him continue execution. This I/O mode is called synchronous I/O or blocking I/O.
asynchronous I/O: Compared to synchronous I/O, the asynchronous I/O does not take a blocking policy on processing I/O scheduling, that is, I am not waiting for I/O completion or return of results, but I am sending the I/O request to the operating system, I continue to execute it, wait until I/O is complete and then notify the i/ o The thread of the operation,
Threads handle events at specific times. In order to be able to implement a thread that can notify a previous I/O operation, the thread must have a loop check for a new event mechanism, which should be processed once a new event is available.