[Project_owners] Threads in mozilla

Davide Carboni dcarboni at crs4.it
Fri Jan 23 19:05:24 EST 2004


Hi,
I successfully deployed a code like this under xpcshell:


function startThread(runnable){
    var 
threadclass=Components.classes["@mozilla.org/thread;1"].getService(Components.interfaces.nsIThread);
    threadclass.init(runnable,512*1024,
            Components.interfaces.nsIThread.PRIORITY_NORMAL,
            Components.interfaces.nsIThread.SCOPE_LOCAL,
            Components.interfaces.nsIThread.STATE_JOINABLE);

}


where runnable implements a method Run() which loops for ever and does 
something useful for me!! The thread loops in background as forked from 
the shell. The problem is that the same function invoked as script from 
a XUL component in Mozilla causes the browser to hang without executing 
the code of method Run()

If the script directly invokes runnable.Run()  the method is executed (I 
can see the results) but the system hangs anyway

I'm missing something, can anyone explain such a behaviour. I expected 
that threadclass.init(...) would fork a new thread, at least this is the 
behaviour in xpcshell.

Davide


More information about the Project_owners mailing list