首页 > 编程语言 > 详细

Java线程--CompletionService使用

时间:2019-11-16 16:37:36      阅读:76      评论:0      收藏:0      [点我收藏+]
原创:转载需注明原创地址 https://www.cnblogs.com/fanerwei222/p/11871911.html

Java线程--CompletionService使用

public static void main(String[] args) throws InterruptedException, ExecutionException {
    ExecutorService executorService = Executors.newFixedThreadPool(5);
    /**
     * 接口
     */
    CompletionService<Integer> completionService = new ExecutorCompletionService<Integer>(executorService);
    completionService.submit(() -> 1);
    /**
     * take()方法 取来 Future, 阻塞型的
     * Future.get()方法获取返回结果
     */
    completionService.take().get();
    /**
     * 接口
     */
    CompletionStage completionStage = null;
    /**
     * CompletionStage/Future 的实现类
     */
    CompletableFuture completableFuture = null;

}

 

Java线程--CompletionService使用

原文:https://www.cnblogs.com/fanerwei222/p/11871911.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!