W
W
websiller2018-08-12 05:00:39
Node.js
websiller, 2018-08-12 05:00:39

Is it possible to execute the same interval in parallel?

There is an interval:

setInterval(function(){
//код, который выполняется 5000 миллисекунд
}, 1000);

That is, after 1 second, will the same interval start in parallel, because the cat inside the function has not yet worked? Or he will wait and score for an interval until the code is executed to the end.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dollar, 2018-08-12
@websiller

JavaScript is single threaded .
setInterval does not create a separate thread, but adds a function call to the queue, which is checked in free time.
Also, two setIntervals will never run in parallel - first one, then the other.
The answer to the question: will wait and score on the interval.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question