Skip to content

Instantly share code, notes, and snippets.

@alfredrichards
Created November 18, 2020 11:57
Show Gist options
  • Save alfredrichards/8234e4117cd2ccfffdc0f0bd13f75c9f to your computer and use it in GitHub Desktop.
Save alfredrichards/8234e4117cd2ccfffdc0f0bd13f75c9f to your computer and use it in GitHub Desktop.
Using a thread created by ExecutorService to run async tasks
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