i did research but didn't find a adequate answer for this question.
Why we need more stages than on stage.
One Thread -> One Big Task(A,B,C,D) VS CompletableFuture with the stages A, B, C, D
So my answer would be the following:
- If I have more stages, i can split the task over different methods and classes
- If I have more stages, it's more fair executing the whole task related to other whole tasks. What I mean with that? Let's say we have in our system only one Thread. If I execute it that way -> One Big Task(A,B,C,D), then my next big Task (W,X,Y,Z) get the chance to be executed, after the first big task is ready. With CompletionStages, there it is more fair: because A,W,B,C,X,Y,Z,D could be the execution order
Are there for my last point any metrics/rules, how small I should split the big task into sub-tasks?
- Is my last point a point for the stages in CompletableFutures?
- Is my first point a point for the stages in CompletableFutures?
- Are there other points for using the stages of CompletableFutures?