|
|
|
|
|
by nogridbag
397 days ago
|
|
Yeah that first example is rather poor. And it uses the word boilerpate to seemingly refer to the stuff unrelated to the async code (class declaration, exception handling, main method). I don't use Java async much, but I guess if you have a utility method named "setTimeout" than the example can simply be: public CompletableFuture<String> fetchData() {
return setTimeout(() -> "Data Fetched", 10000);
}
public void loadData() {
fetchData().thenAccept(System.out::println);
}
Which is simpler or equivalent to the JS example. |
|