I have a test:
Html:
<div id="f1">Empty</div>
<div id="f2">Empty</div>
?
js:
var s1 = function() {
? ??for (i = 1; i < 1000000000; i++) {
? ? ? ??var b = i * i;
? ??}
? ??$('#f1').html('Set');
}
var s2 = function() {
? ??if ($('#f1').html() == 'Empty') {
? ? ? ??$('#f2').html('Multi Thread');
? ? ? ??return;? ? ? ? ? ??
? ??};
? ??$('#f2').html('One Thread');
}
setTimeout(s2,110);
setTimeout(s1,100);?
is there any real reason why setTimeOut() not run in different threads, instead like event model ?
See Question&Answers more detail:os