[Javascript] Avoid multiple onclick

John Deighan jdeighan at pcgus.com
Thu Oct 19 10:04:07 CDT 2006


At 12:13 PM 10/18/2006, Nick Fitzsimons wrote:
All JS code runs in a single thread, so you don't need to worry about
>doing it atomically. That is, it's not possible for any other
>JavaScript code to run until the DoSomething function has run to its
>conclusion. So if DoSomething was called twice, there would be no
>risk of the "if" line executing, and then another instance of the
>function running, making the same check and seing the not-yet-true
>value.

That (i.e. the fact that JS runs in a single thread) answers one 
question I have, and leads to another. I have a progress bar that's 
animated via setInterval(). Then, I run a function to load data that 
can run for quite some time. During that time, the progress bar won't 
run - I assume due to the fact that my load data function is hogging 
the CPU. I'd like to arrange for the load data function to give up 
sufficient CPU to allow the progress bar to run. However, I can't 
find a sleep() or similar function. Is there a way for my load data 
function to give up sufficient CPU for the progress bar animation to run?




More information about the Javascript mailing list