Note that there are some explanatory texts on larger screens.

plurals
  1. POis javascript multithreading possible with IFRAMEs
    text
    copied!<p>I'm currently playing with the idea of using IFRAMEs to implement a very simple multithreading engine. However my initial results are showing me that running in threads is slower than just running in a single thread.</p> <p>My test is:</p> <p><strong>Single Thread</strong></p> <pre><code>var start = new Date().getTime(); for (var i = 0; i &lt; 300; i++) { /* Do costly processor operations */ } debug('Took: ' + new Date().getTime() - start); </code></pre> <p><strong>Multiple Threads</strong></p> <pre><code>var start = new Date().getTime(); // In thread 1 for (var i = 0; i &lt; 100; i++) { /* Do costly processor operations */ } // In thread 2 for (var i = 100; i &lt; 200; i++) { /* Do costly processor operations */ } // In thread 3 for (var i = 200; i &lt; 300; i++) { /* Do costly processor operations */ } // In a callback in the original FRAME (thread) debug('Took: ' + new Date().getTime() - start); </code></pre> <p>So as can be seen, I'm just splitting the work load amongst IFRAMEs (Note code above is only to give a better picture of what I am doing, it is not working code).</p> <p>So I'm thinking that even using FRAMEs FireFox still has only one JS engine? Is this assumption correct? (rendering my research stupid), Are other browsers different?</p> <p>Doing a quick googles I got this article: <a href="http://codediaries.blogspot.com/2009/12/real-javascript-multithreading-using.html" rel="noreferrer">http://codediaries.blogspot.com/2009/12/real-javascript-multithreading-using.html</a></p> <p>However the performance improvements achieved here are more than likely just doing parallel http requests rather than processing power.</p> <p>Thanks for your insights.</p> <p>Guido</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload