2018-10-31
2023-04-24 本文已影响0人
学习者_310
ForkJoinPool pool = new ForkJoinPool(30);
final long begin = System.currentTimeMillis();
try {
pool.submit(() ->
numbers.parallelStream().map(k ->
{try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}return k;
}).collect(Collectors.toList())).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}