@@ -0,0 +1,1658 @@
+import java.util.concurrent.CompletableFuture;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aclass CompletableFutureExample %7B%0A%0A  public static class UserName %7B%0A    private String name;%0A%0A    public void setName(String name) %7B%0A      this.name = name;%0A    %7D%0A%0A    public String getName() %7B%0A      return name;%0A    %7D%0A  %7D%0A%0A  public static class UserPhone %7B%0A    private String phone;%0A%0A    public void setPhone(String phone) %7B%0A      this.phone = phone;%0A    %7D%0A%0A    public String getPhone() %7B%0A       return phone;%0A    %7D%0A  %7D%0A%0A  public static void main(String%5B%5D args) throws Exception %7B%0A%0A    CompletableFuture%3CUserName%3E userName = CompletableFuture.supplyAsync(() -%3E%0A      %7B%0A        System.out.println(%22Creating name%22);%0A        return new UserName();%0A      %7D%0A    ).thenComposeAsync((UserName name) -%3E CompletableFuture.supplyAsync(() -%3E%0A      %7B%0A        try %7B%0A          Thread.sleep(1000); // sleep to show async behavior%0A        %7D catch (InterruptedException e) %7B%0A%0A        %7D%0A%0A        System.out.println(%22Populating name%22);%0A        name.setName(%22Bill%22);%0A        return name;%0A      %7D%0A    ));%0A%0A    CompletableFuture%3CUserPhone%3E userPhone = CompletableFuture.supplyAsync(() -%3E%0A      %7B%0A        System.out.println(%22Creating phone%22);%0A        return new UserPhone();%0A      %7D%0A    ).thenComposeAsync((UserPhone phone) -%3E CompletableFuture.supplyAsync(() -%3E%0A      %7B%0A        System.out.println(%22Populating phone%22);%0A        phone.setPhone(%22800-000-1234%22);%0A        return phone;%0A      %7D%0A    ));%0A%0A    UserName name = userName.get(1500, TimeUnit.MILLISECONDS);%0A    UserPhone phone = userPhone.get();%0A%0A    System.out.println(%22Done! name: %22 + name.getName() + %22 phone: %22 + phone.getPhone());%0A  %7D%0A%7D

use "get" method to wait