| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 692 人关注过本帖
标题:用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
快速回复:用command模拟多线程,这个程序怎么不能运行?
数据加载中...
 
   



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

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