美文网首页
2018-10-31

2018-10-31

作者: 学习者_310 | 来源:发表于2023-04-24 17:52 被阅读0次
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();
}

相关文章

网友评论

      本文标题:2018-10-31

      本文链接:https://www.haomeiwen.com/subject/mpcotqtx.html