How does a single thread handle asynchronous code in JavaScript -


this question has answer here:

i know javascript runs on single thread. also, know when make async ajax call using jquery, code not stop , continues execution serially. response handled callback. question how single thread this? does thread handles callback & stop further code execution when response back?

no, not stop code execution.

the callback gets queued , when there nothing else execute, run.

no 2 things happen @ same time, , scheduling not pre-emptive.

so if keep single thread busy things infinite loops, callback never chance run.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

dataset - MPAndroidchart returning no chart Data available -

post - imageshack API cURL -