gpt4 book ai didi

Java Future 接口(interface)- get(long timeout, TimeUnit unit) 会返回什么?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:45:23 26 4
gpt4 key购买 nike

文档有点困惑。如果超时,该方法将返回什么?文档说“计算结果”,但是如果计算超时怎么办?是否为空?

谢谢

最佳答案

如果计算超时,它将抛出一个 java.util.concurrent.TimeoutException

来自 Java docs :

Exception thrown when a blocking operation times out. Blocking operations for which a timeout is specified need a means to indicate that the timeout has occurred. For many such operations it is possible to return a value that indicates timeout; when that is not possible or desirable then TimeoutException should be declared and thrown.

关于Java Future<V> 接口(interface)- get(long timeout, TimeUnit unit) 会返回什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28047543/

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