java 线程池 带返回值

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();
}
}
上一篇:Spark学习进度四


下一篇:spark submit 常用设置