Concurrency
Basic async invocation
Java
CompletableFuture.runAsync(() -> System.out.println("Hello async!"));
for (int i=0; i<5; i++) {
System.out.print("Hey! ");
Thread.sleep(100);
}
// Hey! Hello async!
// Hey! Hey! Hey! Hey!
GoLang
go fmt.Println("Hello async!")
for i:=0; i<5; i++ {
fmt.Print("Hey! ")
time.Sleep(100 * time.Millisecond)
}
// Hey! Hello async!
// Hey! Hey! Hey! Hey!