Assuming I have a ForkJoinPool setting with degree of parallelism n and that I am invoking parallel computation as follows:
workpool.submit(
() -> {
objects.values().parallelStream().forEach(obj -> {
obj.foo();
});
});
I do this to ensure that the threads created there are created inside the dashboard (I have different system components that need to be isolated). Now suppose the thread in which this is called also runs inside this work pool, and I do:
Future<?> wait = workpool.submit(
() -> {
objects.values().parallelStream().forEach(obj -> {
obj.foo();
});
});
wait.get()
1) ForkJoinPool? n , , , ? , " " ForkJoinPool, ( n ), n , , , . , wait.join() wait.join
( , , , runtimeexception. , join() )
2) forkjoin , runnable "wrapper", () β {}
3) / (, .join() , , , ):
CompletableFuture.supplyAsync(this::mylambdafunction, workpool)
.thenAccept(this::mynextfunction);