Created
November 18, 2020 11:57
-
-
Save alfredrichards/8234e4117cd2ccfffdc0f0bd13f75c9f to your computer and use it in GitHub Desktop.
Using a thread created by ExecutorService to run async tasks
This file contains 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
ExecutorService executorService = Executors.newSingleThreadExecutor(); | |
CompletableFuture.runAsync(task1, executorService) | |
.thenRunAsync(task2, executorService) | |
.join(); | |
executorService.shutdown(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment