Quantcast
Channel: What is the difference between 'CompletionStage' and 'CompletableFuture' - Stack Overflow
Viewing all articles
Browse latest Browse all 4

What is the difference between 'CompletionStage' and 'CompletableFuture'

$
0
0

I have seen an example in each of them, but I need to know exactly what is the difference in deep because I think I can use both of them to get the same result, So I want to know then I can choose the correct one.

What is the benefit of using each of them?

Like this example both works:

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 in the Play framework.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>