实现异步操作CompletableFuture
多个线程异步操作后统一返回执行结果AtomicReference<RespVo> event = new AtomicReference<>();
AtomicReference<Response> meet = new AtomicReference<>(); AtomicReference<ResVo> meet=new AtomicReference<>(); CompletableFuture<Void> completableFuture = CompletableFuture.allOf( CompletableFuture.runAsync(()->{ event.set(event1); }},executorService), CompletableFuture.runAsync(()->{ meet.set(); },executorService) ); completableFuture.join(); event.get();
meet.get();