'How to get desired output from ForkJoinPool.commonPool().submit
Please consider the below existing code segment in the project.
ForkJoinPool.commonPool().submit(() -> updateActions(a, b, c));
public void updateActions(a, b, c){ --some implementation-- }
updateActions is a void method. I'm going to change it to output a Map<String, String> from it. I want to keep the parallel execution behavior as it is and get the map at the end of execution from that.
I modified the code as below but couldn't get any output from it.
ForkJoinTask<Map<String, String>> output = ForkJoinPool.commonPool().submit(() -> updateActions(a, b, c));
changed updateActions method is as below-->
public Map<String, String> updateActions(a, b, c){ --some implementation-- return map; }
How can I change my code according to this requirement?
Solution 1:[1]
realized that the output can be obtained output.get(). Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | PGuru |
