CompletableFuture详解~supplyAsync
生活随笔
收集整理的這篇文章主要介紹了
CompletableFuture详解~supplyAsync
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
supplyAsync 可以支持返回值。
//有返回值 public static void supplyAsync() throws Exception {CompletableFuture<Long> future = CompletableFuture.supplyAsync(() -> {try {TimeUnit.SECONDS.sleep(1);} catch (InterruptedException e) {}System.out.println("run end ...");return System.currentTimeMillis();});long time = future.get();System.out.println("time = "+time); } 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的CompletableFuture详解~supplyAsync的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python 读写配置文件模块: con
- 下一篇: 小甲鱼 OllyDbg 教程系列 (十二