Java中Runnable和Callable接口之间的区别 [英] The difference between the Runnable and Callable interfaces in Java
本文介绍了Java中Runnable和Callable接口之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Java中设计并发线程时使用Runnable和Callable接口有什么区别,为什么要选择其中一个呢?
What is the difference between using the Runnable and Callable interfaces when designing a concurrent thread in Java, why would you choose one over the other?
推荐答案
请参阅此处。
Callable接口类似于
Runnable,因为两个实例的类都被设计为
是
可能由另一个
线程执行。 但是,Runnable没有
返回结果,并且无法抛出
已检查的异常。
这篇关于Java中Runnable和Callable接口之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文