javascript set interval run as seperate thread?
<p>I want to use a timer as a fallback in case I end up in an infinite loop. It seems that set interval is the right way to do this. However, it's not working for me. </p>

<p>From my research, it seems like setInterval should run in a seperate thread in the background, but I don't see it.</p>

<p>Why is this behavior happening? And how do I solve this?</p>

<pre><code>var time = 0;
window.setInterval(function(){time++;}, 1000);
while (true) {
    //stuff done
    if (time &gt;= 5) {
        break;
    }
}
</code></pre>
