1.

How will you differentiate between Asynchronous and Non-blocking ?

Answer»

Asynchronous truly implies not synchronous. If we are making HTTP REQUESTS which are asynchronous, it implies we are not waiting for the server reaction. 

The term Non-Blocking is broadly utilized with IO. For instance non-blocking read/compose calls come back with whatever they can do and anticipate that the user should execute the call once more. Peruse will hold up until it has some information, and put calling thread to rest. 

An asynchronous consider demands an exchange that will be performed in its whole(entirety) yet will finish at some FUTURE time. Non-blocking: This capacity won't pause while on the stack. Synchronous is characterized as occurring simultaneously. Asynchronous is characterized as not occurring simultaneously. 

PLEASE REVIEW the below example to understand BETTER:- 

Synchronous & blocking 

  1. phone.waitForCall(); // Current thread is blocked 
  2. phone.getCall().answer(); 
  3. book.read(); 

Synchronous & non-blocking 

  1. while (!phone.hasCall()) { 
  2. book.readWithTimeout(someTime); 
  3. phone.getCall().answer();   // PhoneCall::answer is called here 
  4. book.read(); 

Asynchronous 

  1. // We can't tell the context where the callback is called. 
  2. // But it is definitely not the current context. 
  3. phone.onRing(PhoneCall::answer); 
  4. book.read(); 


Discussion

No Comment Found