r/java • • Aug 28 '26

JEP draft: Structured Concurrency

https://openjdk.org/jeps/8389757
112 Upvotes

17 comments sorted by

View all comments

Show parent comment

22

u/pron98 Aug 28 '26 edited Aug 28 '26

What doesn't work properly? Why are you switching over the cause? If you want to do some specific handling based on the particular subtask, you could examine their individual results, but the natural thing is obviously to handle the exception in the subtask (in the sequential analogue, a catch block outside a loop, you also don't know which iteration threw the exception, and if you do care about that, you'd similarly move the catch inside the loop). For extra composable configurability you have the joiner.