Skip to content

Instantly share code, notes, and snippets.

@danielblazevski
danielblazevski / hello-word.java
Last active July 21, 2018 19:51
Hello world example of using Futures in Java
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
public class FuturesExample {
// Used to minimize code later, can't do Thread.sleep(t) w/o try/catch statement.
static void delay(long t) {
try { Thread.sleep(t); }
catch (InterruptedException e) {System.out.println(e);}
}