Quantcast
Channel: How is Javascript single threaded? - Stack Overflow
Browsing all 7 articles
Browse latest View live

Answer by brixdan for How is Javascript single threaded?

Definition - Multithreading:Multithreading is a type of execution model that allows multiple threads to exist within the context of a process such that they execute independently but share their...

View Article


Answer by Aisha Hale for How is Javascript single threaded?

Here are the steps: Adding console.log(1) to the JS call stack. time(~0)Executing it. (prints 1 in console) - time(~0)Adding setTimeout(function(){console.log("2");},3000); to the call stack. -...

View Article

Answer by Siddaram H for How is Javascript single threaded?

Javascript uses something called Eventloop for Asynchronous calls.The setTimeout is pushed to EventLoop since it is a callback. and the main thread continues to execute. Once the main completes, Then...

View Article

Answer by Nikhil Sahu for How is Javascript single threaded?

the second parameter of setTimeout takes in the minimum time after which the callback function (first argument) is to be pushed onto the event loop, which is nothing but a queue for callback functions....

View Article

Answer by Brian McGinity for How is Javascript single threaded?

Javascript executes each line in sequence.So you told js:write 1: js writes 1wait 3 seconds and then write 2: ok I'll wait 3 seconds...now what?write 3: ok I'll write 3, by the way, the 3 seconds is...

View Article


Answer by user2864740 for How is Javascript single threaded?

JavaScript (in browsers) doesn't run concurrently2.At most one of the setTimeout callbacks can execute at a time - as there is one JavaScript execution context or "thread".However, the "next scheduled...

View Article

How is Javascript single threaded?

I have a question about the single threaded nature of Javascript.console.log("1");setTimeout(function(){console.log("2");},3000);console.log("3");setTimeout(function(){console.log("4");},1000);The...

View Article
Browsing all 7 articles
Browse latest View live