1、需要掌握概念
//同步,异步,异步回调
//MQ消息中间件

例子:工作邮件、微信、QQ
原理:
同步、异步、异步回调

2、代码
public static void main(String[] args) throws Exception {
//同步,异步,异步回调
//MQ消息中间件
//同步
CompletableFuture<Void> completableFuture1 =
CompletableFuture.runAsync(()->{
System.out.println(Thread.currentThread().getName()
+"\t CompletableFuture.runAsync");
});
completableFuture1.get();
//异步回调
CompletableFuture<Integer> completableFuture2=
CompletableFuture.supplyAsync(()->{
System.out.println(Thread.currentThread().getName()
+"\t CompletableFuture.supplyAsync");
int i = 10/0;
return 1024;
});
completableFuture2.whenComplete((t, u)->{
System.out.println("---t="+t);
System.out.println("---u="+u);
}).get();
}

















![[C语言][小游戏][猜拳游戏]](https://img-blog.csdnimg.cn/8d9cebd0b7e6408ba0e5ddd973a8cfcb.jpeg)

