JavaScript only has one thread of control. This thread handles all
events (i.e., button clicks, windows resizes, etc.) and executes all
javascript code (i.e., everything in a GWT application). Therefore,
it's critical not to block or to loop forever in GWT applications,
because then this single thread will be not be able to process events
(and the web browser will appear to be frozen to the user). Instead,
your code should respond to an event and then return as quickly as
possible so that the JavaScript engine can handle the next event. The
term "event loop" refers to this process of JavaScript continually
looping, handling one event after another. If you like, you can think
about the core of the JavaScript engine in the browser as looking
something like:
while(event = getNextEvent()) {
if(event.getType() == MOUSE_CLICK) {
handleMouseClick(event);
} else if(event.getType() == TIMER_EXPIRATION) {
handleTimerExpiration(event);
}
...
}
If a timer event follows a mouse click event, it cannot get handled
until handleMouseClick() has returned (which, since it must call your
event handler underneath, means that the timer cannot get handled
until your mouse click event handler returns).
Tony
--
Tony Strauss
Designing Patterns, LLC
http://www.designingpatterns.com
http://blogs.designingpatterns.com
On Apr 10, 3:13 am, hezjing <[email protected]> wrote:
> Hi
> Ehmmm ... I'm reading the "Scheduling work: the Timer
> class"<http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#D...>
> ,
> and it says "... Notice that the timer will not have a chance to execute the
> run() method until after control returns to the JavaScript event loop ..."
>
> What is a JavaScript event loop?
>
> --
>
> Hez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---