线程数:
/*
ThisfollowingcodearedesignedandwritenbyWindy_sk
Youcanuseitfreely,butumustheldallthecopyrightitems!
*/
vartotal=505;
varthread_num;
varpre_thread;
varthread=newArray();
varcompleted=0;
varstart_time=null;
for(i=0;i
functioninit_para(){
thread_num=parseInt(the_thread.value);
if(isNaN(thread_num))thread_num=10;
pre_thread=Math.floor(total/thread_num);
result.innerText="";
bar1.style.width="0%";
bar2.style.width="100%";
bar.style.display="";
}
functioncheck_all(){
checkall.disabled=true;
init_para();
for(vari=0;i
thread[i]=[setInterval("thread["+i+"][1]
functioncheck_unit(num){
if(completed==0)start_time=newDate;
cbox[num].checked=checkall.checked;
completed++;
varcur_rate=Math.round(completed*100/total);
show.innerText=completed+"/"+total+":"+cur_rate+"%";
bar1.style.width=cur_rate+"%";
bar2.style.width=(100-cur_rate)+"%";
if(completed==total){
completed=0
checkall.disabled=false;
result.innerText="("+total+"单元/"+thread_num+"线程,总共耗时:"+((newDate)-start_time)+"ms)";
}
}
下面是运行效果
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]