File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
src/main/java/com/test/multithreading Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .test .multithreading ;
2+
3+ import java .util .concurrent .CompletableFuture ;
4+ import java .util .concurrent .ExecutionException ;
5+
6+ public class CompletableFutureExample {
7+ /**
8+ * https://javasampleapproach.com/java/java-8/java-8-completablefuture-
9+ * handle-exception
10+ *
11+ * @param args
12+ * @throws InterruptedException
13+ * @throws ExecutionException
14+ */
15+ public static void main (String [] args ) throws InterruptedException ,
16+ ExecutionException {
17+ CompletableFutureExample obj = new CompletableFutureExample ();
18+ obj .createCompletableFuture ();
19+ }
20+
21+ public void createCompletableFuture () throws InterruptedException ,
22+ ExecutionException {
23+ CompletableFuture .runAsync (new Task ()).get ();
24+ }
25+ }
26+
27+ class Task implements Runnable {
28+
29+ @ Override
30+ public void run () {
31+ System .out .println ("Hello Task" );
32+
33+ }
34+
35+ }
You can’t perform that action at this time.
0 commit comments