首页 > 编程语言 > 详细

java 线程池 带返回值

时间:2021-01-10 22:47:27      阅读:38      评论:0      收藏:0      [点我收藏+]
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class E {
public static void main(String[] args) {
ExecutorService service = Executors.newFixedThreadPool(1);
Future<String> submit = service.submit(() -> "sadasd");
try {
System.out.println(submit.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
service.shutdown();
}
}

java 线程池 带返回值

原文:https://www.cnblogs.com/bzdofj/p/14258877.html

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