Possible Duplicate:
JavaScript multithreading
When I open a web page in browser, how many threads are started to render the DOM and execute the Javascript code?
Is it possible to execute Javascript functions with multi-threads?
Possible Duplicate:
JavaScript multithreading
When I open a web page in browser, how many threads are started to render the DOM and execute the Javascript code?
Is it possible to execute Javascript functions with multi-threads?
The short answer is no, you cannot run multithreaded code in javascript.
The longer answer is that you can simulate it. This question on SO might be helpful: Multithreaded JavaScript how to?
Javascript code runs in a single thread . You can not start seperate thread but you still can use asynchronous functions to achieve that like setTimeOut and setInterval .
In general there is only one UI thread, but you can run JS in parallel with WebWorkers in HTML5.
You can use WebWorkers for threads, but it cant work with dom. Also you may try simulate it by setInterval
Another idea that people use at times is to make use of iframes. If your application can be modeled as set of iframes(like facebook), you can leverage this. Google chrome is highly optimized for this. Javascript in each frame executes in a separate execution context and hence can be parallelized.