Recurring JavaScript functions

I have two Javascript functions.

On is set to repeat every 5 seconds and the other is set to activate on an event (a click on a button).

They both access the same set of variables - one function setting the variables the other one reading them.

How does Javascript react in the rare occasions where my manually activated function takes place at the same time as my recurring one?

Are they run synchronously or are they "stacked" and running one after another?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Not sure how javascript handles this. However you could have the setEvent call the getEvent immediately to be sure it doesn't get behind?

I think it is implementation based. In IE Javascript is synchronous. So if any call is blocking it won't call another function.

var i = 0;
setInterval("i++;window.status=i", 1000);
setTimeout("alert('Hello');", 3000);
//setTimeout("GetURL();", 3000);

However in FF it seems to be opposite.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
In the click event, cancel the interval at the beginning and restart it at the end.

It should be noted that this (setInterval("i++;window.status=i", 1000);) does not mean that the specified code will execute every 1 second (1000 msec). It means that every 1 sec the specified code will be queued up to be executed. It could be 1012 msec between executions one time, 1000 exactly another, 997 another time, and 1003 msec yet another time. The exact interval will depend on processor utilization/availability.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.