gpt4 book ai didi

java - Parallel Stream.forEach 抛出的异常

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:44:22 26 4
gpt4 key购买 nike

Consumer 抛出异常时,我用 Google 搜索了从并行 StreamforEach 方法抛出的内容,但没有没有找到任何关于它的信息。它会抛出类似于 C# 的 AggregateException 或其他东西的东西吗?

最佳答案

根据 http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinTask.html#fork() 将异常转发给调用者

Rethrown exceptions behave in the same way as regular exceptions, but, when possible, contain stack traces (as displayed for example using ex.printStackTrace()) of both the thread that initiated the computation as well as the thread actually encountering the exception; minimally only the latter.

关于java - Parallel Stream.forEach 抛出的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29416266/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com