Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Avoid multiple onclick


  • From: jdeighan at pcgus.com (John Deighan)
  • Subject: [Javascript] Avoid multiple onclick
  • Date: Thu Oct 19 10:05:19 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?