代码如下:
public Map method(final String nsrdzdah,final String nd,.....){
Map tax=new HashMap<>();
final ExecutorService executor=Executors.newCachedThreadPool();
fianl ArrayList>> futures=new ArrayList<>();
funtures.add(executor.submit(new Callable<Map<String,Object>>(){
@Override
public Map<String,Object> call() throws Exception{
Map<String,Object> taxpayerCreLev = taxpayerCreLev(nsrdzdah,nd,lpbm);
return taxpayerCreLev;
}
}));
funtures.add(executor.submit(new Callable<Map<String,Object>>(){
@Override
public Map<String,Object> call() throws Exception{
Map<String,Object> decCol = decCol(nsrdzdah,nd,lpbm);
return decCol;
}
}));
funtures.add(executor.submit(new Callable<Map<String,Object>>(){
@Override
public Map<String,Object> call() throws Exception{
Map<String,Object> illegalInforGroup = illegalInforGroup(nsrdzdah,sssq_q,sssq_z,lpbm);
return illegalInforGroup;
}
}));
funtures.add(executor.submit(new Callable<Map<String,Object>>(){
@Override
public Map<String,Object> call() throws Exception{
Map<String,Object> taxesOwed = taxesOwed(nsrdzdah,nd,syqzh);
return taxesOwed;
}
}));
while(true){
if(futures.size()==0){
break;
}
.
.
.
.
.
}
现在我需要把线程池这一部分的内容从该service层提取出来,做一个工具类也可以,其他实现也可以,自己试过用ThreadPoolExecutor这个类来写工具类,但是该类构造器内部需要一个队列,查看该队列存放的数据类型,只能是Runnable接口,而不能是我需要的Callable接口的。求助,求大神指导其他写法。C币不够了,见谅!