In Node, each block of code is synchronized. Node uses collaborative multitasking; the only time another piece of code can run when the first part of the code is returned.
This is the driving force behind its event-driven design: you ask for something slow for you (for example, reading from a file), and then you specify another function that will be executed when this slow operation is completed. The first function returns, and Node can run other functions while it waits for an I / O operation to complete. When the I / O is ready, and all other functions are completed, your continuation will be called.
Synchronization is not required when you are in full control of when your code will work. In fact, each function is synchronized.
source share