boolean checkMain(Set<> hosts,long timeout, TimeUnit unit) throws InterruptedException{
ExecutorService exec = new CachedThreadPool();
final AtomicBoolean hasNewMail = new AtomicBoolean(false);
try{
for(final String host : hosts){
exec.execute(
new Runnable(){
public void run(){
if(checkMain(host)){
hasMail(true);
}
}
}
);
}
}finally{
exec.shutdown();
exec.awaitTermination(timeout,unit);'
}
return hasNewMail.get();
}
私有Executor执行任务
猜你喜欢
转载自blog.csdn.net/weixin_37632716/article/details/118638610
今日推荐
周排行