[Project_owners] JavaScript threads

Christopher Ottley xknight at users.sourceforge.net
Mon Jan 3 10:00:58 EST 2005


Sudhakar Chandra wrote:

> 1. Is threading even possible in JS?

There's a XPCOM component that you should be able to play with 
@mozilla.org/thread;1 
(http://www.xulplanet.com/references/xpcomref/comps/c_thread1.html) 
however the problem is that the JS engine apparently runs *everything* 
in one thread when interpreting code (even if you use that component). 
To get a multithreaded effect basically you would have to use 
setInterval or a recursive setTimeout and process each request you make 
while not blocking the UI or anything else from running. If you really 
want multithreaded processing without using setInterval or setTimeout 
you'd have to write your code in C++.

Regards,
Christopher.



More information about the Project_owners mailing list