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

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模擬多線程,轉載需保留來源!

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

主站蜘蛛池模板: 91精品国产高清 | 四虎网站在线 | 婷婷毛片 | 色视频网站色视频播放 | 在线观看精品视频一区二区三区 | 美女视频黄是免费的 | 激情视频一区 | 91不卡| 思思久久99热只有精品 | 久久青草免费91线频观看站街 | 热久久久久久 | 亚洲美女一级毛片 | 天天色官网 | 一区中文字幕 | 91青青国产在线观看免费 | 欧美成人亚洲国产精品 | 一区二区免费看 | 久久福利青草狠狠午夜 | 女人18毛片久久鬼色 | 狠狠五月深爱婷婷网 | 黑人美国一级一级爰片 | 国产嫩草在线观看 | 日本欧美一区二区 | 久久亚洲精品中文字幕三区 | 亚洲欧洲精品成人久久曰影片 | 日本一区二区在线免费观看 | 奇米久草 | 高清国产美女一级a毛片录 高清国产美女一级毛片 | 国产小视频网站 | 午夜日韩视频 | 午夜亚洲国产成人不卡在线 | 久久成人亚洲香蕉草草 | 国产福利写真视频在线观看 | 久中文字幕中文字幕亚洲无线 | 亚洲国产精品久久网午夜 | 美女色黄 | 亚洲1234区乱码 | 久久综合综合久久 | 国产成人精品一区二区不卡 | 国产精品嫩草影院在线观看免费 | 激情网站视频 |