What I am trying to do is calculate the depth of a tree structure asynchronously, I will have the first level of the tree and I want to kick off an asynchronous thread to calculate the depth of each of the nodes separately.
During the course of the calculations there might obviously be a fork in the tree, at which point I want to kick of an additional thread to calculate that branch.
I have got this working pretty much however I need to do some finishing up logic when all of these futures have completed. But I am having trouble with the additional CompletableFutures that are spawned along the way.
What method would I use to save up all of the starting CompletableFutures + the ones that are dynamically created along the way and have a way to await all of them to complete before doing any additional logic.