gpt4 book ai didi

java - Java中Runnable接口(interface)和Callable接口(interface)的区别

转载 作者:行者123 更新时间:2023-12-02 04:08:32 26 4
gpt4 key购买 nike

在 Java 中设计并发线程时,使用 RunnableCallable 接口(interface)有什么区别,为什么要选择其中一个?

最佳答案

参见解释here .

The Callable interface is similar to Runnable, in that both are designed for classes whose instances are potentially executed by another thread. A Runnable, however, does not return a result and cannot throw a checked exception.

关于java - Java中Runnable接口(interface)和Callable接口(interface)的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56703000/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com