使用ThreadPoolExecutor提交和执行方法有什么区别 [英] What is the difference between submit and execute method with ThreadPoolExecutor
本文介绍了使用ThreadPoolExecutor提交和执行方法有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现有两种方法(提交和执行)将Runnable添加到线程池中,有什么区别?
I found there are two ways (submit and execute) to add a Runnable into a thread pool, what is the difference?
推荐答案
区别在于执行
未返回 Future
,因此您无法等待完成 Runnable
并获取它使用它抛出的任何异常。
The difference is that execute
doesn't return a Future
, so you can't wait for the completion of the Runnable
and get any exception it throws using that.
这篇关于使用ThreadPoolExecutor提交和执行方法有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文