when does settimeout execute the delayed code?

P

petermichaux

Hi,

setTimeout(code, delay)

When the delay of a setTimeout expires it is time to execute the code.
If the browser is executing some other JavaScript will the setTimeout
code interupt or wait until the browser is not busy doing other things?
(Can the browser execute mutliple threads?)

Thanks,
Peter
 
R

Richard Cornford

setTimeout(code, delay)

When the delay of a setTimeout expires it is time to
execute the code.
If the browser is executing some other JavaScript will
the setTimeout code interupt or wait
Wait.

until the browser is not busy doing other
things?

More or less, depending on the browser.
(Can the browser execute mutliple threads?)

A single browser window/ECMAScript global environment cannot execute
multiple threads (javascript is not multi-threaded). It may be possible
for different frames to act as different browsers and so be executing
script in one frame at the same time as executing script in another.
There is no evidence that current browsers do so.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top