当前位置:   article > 正文

多线程-线程池执行多线程,如何保证线程执行完成后再执行下面的业务逻辑_怎么在executor后执行其它逻辑

怎么在executor后执行其它逻辑

public static void main(String[] args) throws ExecutionException, InterruptedException {

ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(3, 3, 60L, TimeUnit.SECONDS, new LinkedBlockingDeque<>()); Callable callable = new Callable<String>() {

@Override public String call() throws Exception {

System.out.println(1); Thread.sleep(1000); return "2"; } };

Future<String> submit = poolExecutor.submit(callable);

String s = submit.get();//等线程执行完返回数据 System.out.println(s); }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/1008727
推荐阅读
相关标签
  

闽ICP备14008679号