等待所有线程都执行完毕 停止线程
int taskcount=futurelist.size(); //获取所有已提交的线程
int done=0;//已完成
while(done<taskcount){
done=0
for(Futrre(T) t:List){ //拿到所有的返回值futre
isDone(t){
done++;
continue;
}
}
try{
Thread.sleep(500) ; //当前线程等待半秒钟
}catch(Interupted e){
}
}
//判断线程是否结束
isdone(Future t){
if(t==null || t.isconcelled() || t.isdone()){
return truel;
}
}
浙公网安备 33010602011771号