Quantcast
Channel: Does setTimeout() really execute in parallel? - Software Engineering Stack Exchange
Viewing all articles
Browse latest Browse all 4

Does setTimeout() really execute in parallel?

$
0
0

Consider following JavaScript code:

function foo(ary) {  // some long operation on ary}function bar(ary) {  // some long operation on ary}function baz(ary) {  // some long operation on ary}function main(ary) {  setTimeout(foo, 0, ary);  setTimeout(bar, 0, ary);  setTimeout(baz, 0, ary);}main([some large array]);

From MDN setTimeout():

Code executed by setTimeout() is run in a separate execution context to the function from which it was called.

But does this mean it executes in parallel to any other code that is currently in process?

Considering the example I posted above, assuming a very large array being processed by 3 function, each doing a very long operation on it but are independent of each other, will the 3 functions execute in parallel?

Is there any way on showing the execution of (multiple) setTimeouts, maybe using Chrome Dev Tools?


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>