一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

JS模擬多線程

var Thread = {
 runNum : 0,  //當(dāng)前正式運行的線程數(shù)
 maxNum : 10, //最大同時執(zhí)行的線程數(shù) -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,  //當(dāng)前正式運行的線程數(shù)
 maxNum : 5, //最大同時執(zhí)行的線程數(shù) -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技術(shù)JS模擬多線程,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 国产一区二区精品久久 | 五月婷中文字幕 | 美女扒开腿被男人猛视频 | 久久久噜噜噜久久 | 老司机51精品视频在线观看 | 6699久久国产精品免费 | 免费视频国产 | 成人观看天堂在线影片 | 国产成人精品三区 | 欧美一级一片 | 色多多在线观看 | 伊人久久网国产伊人 | 在线观看视频一区二区 | 久久99久久精品国产只有 | 正在播放一区 | 91精品免费国产高清在线 | 看全色黄大色黄女片做 | 九九re热| 成人看的午夜免费毛片 | 亚洲制服欧美自拍另类 | 男人女人做刺激视频免费 | 日本www视频在线观看 | 久久亚洲福利 | 亚洲天堂日韩在线 | 欧美成人全部费免网站 | 欧美成人精品欧美一级乱黄 | gogo人体大胆色妇 | 亚洲国产一区二区三区亚瑟 | 欧美人与禽交片在线播放 | 国产91综合 | 国产无套在线观看视频 | 中文字幕一区二区三区 精品 | 成人免费观看黄a大片夜月 成人免费观看视频 | 伊人任线任你躁 | 在线私拍国产福利精品 | 亚洲人人爱 | 黄视频网站在线观看 | 91精品人成在线观看 | 国产福利一区二区三区在线视频 | 91精品国产高清久久久久久 | 激情欧美在线 |