| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + package com.winterbe.java8.samples.concurrent; | ||
| 2 | + | ||
| 3 | + import java.util.concurrent.CompletableFuture; | ||
| 4 | + import java.util.concurrent.ExecutionException; | ||
| 5 | + | ||
| 6 | + /** | ||
| 7 | + * @author Benjamin Winterberg | ||
| 8 | + */ | ||
| 9 | + public class CompletableFuture1 { | ||
| 10 | + | ||
| 11 | + public static void main(String[] args) throws ExecutionException, InterruptedException { | ||
| 12 | + CompletableFuture<String> future = new CompletableFuture<>(); | ||
| 13 | + | ||
| 14 | + future.complete("42"); | ||
| 15 | + | ||
| 16 | + future | ||
| 17 | + .thenAccept(System.out::println) | ||
| 18 | + .thenAccept(v -> System.out.println("done")); | ||
| 19 | + | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments