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
Post a Comment