多线程启动及获取返回值
public class Runtask {
public static void main(String[] args) {
ExecutorService service = Executors.newFixedThreadPool(10);
*CompletionService<List> completionService = new ExecutorCompletionService<List>(service);*
List<List> futures = new ArrayList<List>();
for(int i=0;i<3;i++){
completionService.submit(new CallableImp(30));
}
for(int j=0;j<3;j++){
try {
futures.add(completionService.take().get());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
class CallableImp implements Callable<List>{
private int num;
public CallableImp(int num){
this.num = num;
}
@Override
public List call() throws Exception {
List lis = new ArrayList<Integer>();
return lis;
}
}