中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

JS模擬多線程

var Thread = {
 runNum : 0,  //當前正式運行的線程數
 maxNum : 10, //最大同時執行的線程數 -1表示不限
 commandList : new Array(), 
 start : function(){
  //window.status = this.runNum; 
  if(this.maxNum != -1 && this.runNum >= this.maxNum){   
   return; 
  }
  if(this.commandList.length <= 0){  
   this.runNum = 0;
   return false; 
  }  
  this.runNum++;
  var _this =this;  
  var tFun = function(){
   if(!_this.commandList[0]) return;
   var command = _this.commandList[0].shift();   
   command.apply(_this,_this.commandList[0].concat(
    function(){  //alert(2)     
     if(_this.runNum > 0)_this.runNum--; 
     setTimeout(function(){_this.start.apply(_this)},1);     
    }));
   _this.commandList.shift(); 
  }
  setTimeout(tFun,1);  
  setTimeout(function(){_this.start.apply(_this)},10);
 }
}

<script src="prototype.js"></script>
<script type="text/Javascript" defer="defer">
function test(obj,info,callback){ 
 callback = callback || new Function();
 new Ajax.Request('test.xml',{method:'get',
  onSuccess:function(o){

   $(obj).innerHTML += info + '完成<br>';
   callback('完成');
  },
  onFailure : function(o){
   $(obj).innerHTML += info + '失敗<br>';
   callback('失敗');
  },
  onComplete : function(o){
   document.body.scrollTop = 9999;
  }
 });
}

var Thread = {
 runNum : 0,  //當前正式運行的線程數
 maxNum : 5, //最大同時執行的線程數 -1表示不限
 commandList : new Array(), 
 start : function(){
  //window.status = this.runNum; 
  if(this.maxNum != -1 && this.runNum >= this.maxNum){   
   return; 
  }
  if(this.commandList.length <= 0){  
   this.runNum = 0;
   return false; 
  }  
  this.runNum++;
  var _this =this;  
  var tFun = function(){
   if(!_this.commandList[0]) return;
   var command = _this.commandList[0].shift();   
   command.apply(_this,_this.commandList[0].concat(
    function(){  //alert(2)     
     if(_this.runNum > 0)_this.runNum--; 
     setTimeout(function(){_this.start.apply(_this)},1);     
    }));
   _this.commandList.shift(); 
  }
  setTimeout(tFun,1);  
  setTimeout(function(){_this.start.apply(_this)},10);
 }
}

for(var i = 0; i < 100 ; i++){
 Thread.commandList.push(new Array(test,document.body,i+1));
};
Thread.start();
</script>
<body>
</body>

JavaScript技術JS模擬多線程,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 久草精品在线 | 一级毛片视频 | 国产在线a| www.99久久.com | 日韩精品免费在线观看 | 不卡av在线 | 国产小视频在线观看 | 欧美精品一区三区 | 伊人网伊人 | 欧美福利视频一区 | 在线看亚洲| 欧美精品中文字幕久久二区 | 桃色五月 | 性精品| 日本在线中文 | 天天综合网天天综合色 | 日韩不卡一区二区三区 | 亚洲一区二区三区免费在线 | 欧美精品在线播放 | 亚洲国产区 | 视频一区二区三区四区五区 | 中文字幕一区二区三区四区五区 | 99精品热视频 | 一区二区日韩 | 水蜜桃久久夜色精品一区 | 一区二区伦理电影 | 欧美日韩综合视频 | 中文字幕国产精品 | 日韩毛片在线观看 | 日本不卡视频在线播放 | 黑色丝袜三级在线播放 | 国产精品久久毛片av大全日韩 | 在线观看国产精品一区二区 | www97影院| 中文一区 | 亚洲成人三级 | 亚洲精品电影网在线观看 | 成年人视频在线免费观看 | 欧美日韩中文字幕在线 | 亚洲毛片一区二区 | 亚洲成av人片在线观看 |