Skip to content

Instantly share code, notes, and snippets.

@Yatharth0045
Created April 3, 2019 01:22
Show Gist options
  • Save Yatharth0045/ea8170832f8f848a30503d46cb6e7946 to your computer and use it in GitHub Desktop.
Save Yatharth0045/ea8170832f8f848a30503d46cb6e7946 to your computer and use it in GitHub Desktop.
An example to show runAsync method of completablefuture.
import java.util.concurrent.CompletableFuture;
class Test {
public static void main(String[] args) {
CompletableFuture completableFuture = CompletableFuture.runAsync(() -> {
System.out.println(Thread.currentThread().getName() + " Runnable Call to be executed by another thread");
});
System.out.println(Thread.currentThread().getName() + " Main Thread");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment