在线不卡日本ⅴ一区v二区_精品一区二区中文字幕_天堂v在线视频_亚洲五月天婷婷中文网站

  • <menu id="lky3g"></menu>
  • <style id="lky3g"></style>
    <pre id="lky3g"><tt id="lky3g"></tt></pre>

    ListenableFuture包裝

    本文介紹如何使用Future的異步處理。

    使用JdkFutureAdapters包裝

    final List listenableFutures = futures.stream().map(JdkFutureAdapters::listenInPoolThread).collect(Collectors.toList()); Futures.successfulAsList(listenableFutures,new FutureCallback(){ @Override public void onSuccess(@Nullable Object o) { } @Override public void onFailure(Throwable throwable) { } } );}

    JAVA8的whenComplete

    CompletableFuture.supplyAsync(() -> modelConvertHandle(mes), MODEL_REBUILD_EXE) .whenComplete((r, e) -> { if (e != null) { LOG.error(“manual sync is failed,Cost Time:{} ms”, System.currentTimeMillis() – current, e); } else { LOG.info(“manual sync is success,response is:{},Cost Time:{} ms”, r, System.currentTimeMillis() – current); } manualSyncFinish(); });

    在whenCompleteAsync除非特別指定,都是默認(rèn)使用的forkJoin線程池。

    鄭重聲明:本文內(nèi)容及圖片均整理自互聯(lián)網(wǎng),不代表本站立場(chǎng),版權(quán)歸原作者所有,如有侵權(quán)請(qǐng)聯(lián)系管理員(admin#wlmqw.com)刪除。
    上一篇 2022年7月10日 18:29
    下一篇 2022年7月10日 18:29

    相關(guān)推薦

    聯(lián)系我們

    聯(lián)系郵箱:admin#wlmqw.com
    工作時(shí)間:周一至周五,10:30-18:30,節(jié)假日休息