标题:用command模拟多线程,这个程序怎么不能运行?
只看楼主
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
结帖率:79.17%
 问题点数:0 回复次数:1 
用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 编辑 ]
搜索更多相关主题的帖子: function command 多线程 title 
2011-02-09 23:39
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
得分:0 
注意大小写:
17:    var resultTemp = document.createElement("span");
18:    document.body.insertBefore(resultTemp,document.body.lastChild);
19:    document.body.insertBefore(document.createElement("br"),document.body.lastChild);
29:    document.body.removeChild(temp.nextSibling);
30:    document.body.removeChild(temp);


~~~~~~~~~~~~~~~好好学习~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2011-02-10 10:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-331972-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.567046 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved