Javascript : Non blocking / Async example

/** * Created by Aseem on 12/7/16. */ console.log("1: Start app") var slowProcess = setTimeout(function(){ console.log("2: app processing async - non blocking "); },1000); console.log("3: Exit app")

 

The out of this is non blocking, which mean the flow will not wait  or get blocked for slowProcess

Sample console output

➜ async git:(master) ✗ node nonBlocking.js
1: Start app
3: Exit app
2 : app processing async – non blocking

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.