用command模拟多线程,这个程序怎么不能运行?
<html><head>
<title> emus -- 用command模拟多线程 </title>
</head>
<body>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var commandList = [];
function executeCommands(){
if (commandList.length > 0) {
commandList.shift()();
}
}
function StartNewTask(){
var resultTemp = document.creatElement("span");
document.body.insertBefore(resultTemp, document.body.LastChild);
document.body.insertBefore(document.creatElement("br"), document.body.LastChild);
resultTemp.innerText = 0;
commandList.push(function(){simThread(resultTemp, 0);});
}
function simThread(temp, n){
temp.innerText = temp.innerText-(-n);
if(n<1000)
commandList.push(function(){simThread(temp, ++n);});
else {
document.body.removechild(temp.nextsibling);
document.body.removechild(temp);
}
}
window.onload = function(){setInterval("executeCommands()", 1);}
//-->
</SCRIPT>
<button onclick="StartNewTask()">start</button>
<BR> <BR>
</body>
</html>
用command模拟多线程.rar
(960 Bytes)
[ 本帖最后由 vfdff 于 2011-2-10 00:01 编辑 ]