Created
October 23, 2024 19:07
-
-
Save muhdkhokhar/1bf07487442f6a2c57550eec851b9fec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws InterruptedException, ExecutionException { | |
List<Integer> list1 = List.of(1, 2, 3); | |
List<Integer> list2 = List.of(4, 5, 6); | |
List<Integer> list3 = List.of(7, 8, 9); | |
CompletableFuture<Void> future1 = CompletableFuture.runAsync(() -> processList1(list1)); | |
CompletableFuture<Void> future2 = CompletableFuture.runAsync(() -> processList2(list2)); | |
CompletableFuture<Void> future3 = CompletableFuture.runAsync(() -> processList3(list3)); | |
// Wait for all futures to complete | |
CompletableFuture.allOf(future1, future2, future3).join(); | |
System.out.println("All lists processed."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment