作者热门文章
- html - 我的下拉菜单的内容关闭得太快
- c# - 使用 Html Agility Pack 从网页中的表中获取值而不使用 "SelectNode'
- html - 内容容器下的 CSS 下拉菜单
- html - 如何停止嵌套列表重叠父列表?
这是令我困惑的代码:
public Integer getInteger(BlockingQueue<Integer> queue) {
boolean interrupted = false;
try {
while (true) {
try {
return queue.take();
} catch (InterruptedException e) {
interrupted = true;
// fall through and retry
}
}
} finally {
if (interrupted)
Thread.currentThread().interrupt();
}
}
看起来try block 不会因为While(true) block 而停止,但我被告知finally block 总是在try block 结束后执行。那么finally block 什么时候执行呢?
最佳答案
当存在另一个不是从 InterruptedException 派生的异常时
关于java - 如果try block 中有 "Where (true)" block ,是否会到达finally block ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33272246/
我是一名优秀的程序员,十分优秀!