Drawback of mixing Blocking and Non-Blocking Code

When doing multiple operations we may come across a situation where we accidentally combine blocking and non blocking operations which may lead some operations to execute even before their required operations are not completed. For example, if a file content is printed on the console even before the file has been read. To overcome this situation it is always preferred to write non-blocking code for related functions.



Blocking and Non-Blocking in Node

Node is based on an event-driven non-blocking I/O model. This article discusses what does Blocking and Non-Blocking in Node means.

Table of Content

  • What is Blocking?
  • What is Non-Blocking ?
  • How Concurrency and throughput is handled?
  • Drawback of mixing Blocking and Non-Blocking Code

Similar Reads

What is Blocking?

It refers to the blocking of further operation until the current operation finishes. Blocking methods are executed synchronously. Synchronously means that the program is executed line by line. The program waits until the called function or the operation returns....

What is Non-Blocking ?

...

How Concurrency and throughput is handled?

It refers to the program that does not block the execution of further operations. Non-Blocking methods are executed asynchronously. Asynchronously means that the program may not necessarily execute line by line. The program calls the function and move to the next operation and does not wait for it to return....

Drawback of mixing Blocking and Non-Blocking Code

...

Contact Us