ExecutorsService 中的 submit和 execute的区别

闲来无事,写点代码练练手。于是就看了下ExecutorService常用的提交任务的方法:

 Future submit(Callable task);
 Future submit(Runnable task, T result);
Future submit(Runnable task);

而ExecutorService extends Executor,

Executor中
void execute(Runnable command);

从以上的方法签名上,区别已经很明显了,主要是submit方法可以通过Future来获取提交结果。

多看API,可以拓展设计和实现思路。JDK很多设计非常优秀。

另外,喜马拉雅 免费听书
http://xima.tv/zZCVgq
《人类的群星闪耀时》,茨威格大作,催人振奋!码农也应该读写人文!

让我们充满激情的迎接每一天吧。

你可能感兴趣的:(ExecutorsService 中的 submit和 execute的区别)