I saw an example in each of them, but I need to know exactly what the difference is in depth. Because sometimes I think I can use both of them to get the same result. So I want to know so that I can choose the right one?
What is the advantage of using each of them?
As in this example, both work:
public CompletionStage<Result> getNextQueryUUID() { return CompletableFuture.supplyAsync(() -> { String nextId = dbRequestService.getNextRequestQueryUUID(); return ok(nextId); }, executor); } public CompletableFuture<Result> getNextQueryUUID() { return CompletableFuture.supplyAsync(() -> { String nextId = dbRequestService.getNextRequestQueryUUID(); return ok(nextId); }, executor); }
This example runs on the Play framework .
java concurrency completable-future
Ebraheem Alrabee '
source share