I'm working on some java code, which processes multiple REST calls
call1()
call2()
call3()
...
I want to parallelize these calls, but perform my main code synchronously. I made a POC with lamba and a parallel stream:
List<Runnable> list = new ArrayList();
list.add(() -> {call1()});
list.add(() -> {call2()});
list.add(() -> {call3()});
list.add(...);
list.parallelStream()
.forEach(Runnable::run);
Do you have another solution? I also checked to use async calls from Jersey client instead, but this would need more code changes.