View Full Version : Newbie question - multi threading for data retrievals?

13 Oct 2011, 4:16 AM
I'm evaluating 'ext JS4' for a new project, and as a JS newbie I'm hoping somebody can help me with some ***** level answers to a basic question.

I'm hoping to build a data query tool using ext JS4. The tool would have multiple data views open to allow the user to change query scope, display order etc.

Typically for a Windows app I'd place the underlying data queries in a background thread,thus allowing the user to continue with other user selections whilst the first query awaits completion.

Does extJS4 include the same type of threading facilities?

13 Oct 2011, 4:52 AM
There's no such thing as "threading" in javascript, but yes, you can request new data while the UI stays responsive by using Ajax.

13 Oct 2011, 4:55 AM
Browsers/Javascript are single-threaded in nature; however, if you are concerned w/ requests to the server being non-blocking -- well that is what AJAX is...

Ajax provides the ability to make asynchronous calls to the server, and therefore allow the browser to continue its execution path (and potentially even perform a context switch to allow the browser to reflow/repaint).

In short - it does not, nor does Javascript, allow multi-threading; however, I think that what you're more concenered with is UI locking while requests are made, and yes - that can be handled by the use of AJAX calls to the server, and timers for long running client-side processes.

I highly recommend you pickup the book "High Performance Javascript", ISBN: 9780596802790. Read the first chapter, entitled "Loading and Execution". It talks primarily about non-blocking scripts.