ForkJoinPool的get和join方法的区别
解决方法:
get方法可以捕捉ExecutionException和InterruptedException异常
ForkJoinPool pool = new ForkJoinPool();
SignatureSendAnalysisTask task = new SignatureSendAnalysisTask(page,pageCount);
ForkJoinTask<Integer> submit = pool.submit(task);
try {
Integer integer2 = submit.get();
} catch (ExecutionException e) {
}catch (InterruptedException e) {
}
join方法不可以捕捉ExecutionException和InterruptedException异常,代码编译不过去,以下代码编译不了,报错
ForkJoinPool pool = new ForkJoinPool();
SignatureSendAnalysisTask task = new SignatureSendAnalysisTask(page,pageCount);
ForkJoinTask<Integer> submit = pool.submit(task);
try {
Integer integer2 = submit.join();
} catch (ExecutionException e) {
}catch (InterruptedException e) {
}