Skip to content

Commit 6c268dc

Browse files
committedSep 22, 2015
test
2 parents 5738a90 + 28e7878 commit 6c268dc

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
 

‎contents/Does-finally-always-execute-in-Java.md

+29
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
##问题
22

3+
<<<<<<< HEAD
34
有一个 try/catch 代码块,其中包含一个打印语句。finally代码块总会被调用么?
45

56
示例:
7+
=======
8+
有一个 try/catch 代码块,其中包含一个打印语句。finally代码块总会被执行么?
9+
10+
示例:
11+
12+
>>>>>>> 28e7878b6828743ba520b991713ff3e6a1fc0c22
613
``` java
714
try {
815
something();
@@ -19,15 +26,27 @@ finally {
1926
##回答
2027

2128
1. ```finally``` 将会被调用。
29+
<<<<<<< HEAD
2230
只有以下情况 ```finally``` 不会被调用:
31+
=======
32+
33+
只有以下情况 ```finally``` 不会被调用:
34+
>>>>>>> 28e7878b6828743ba520b991713ff3e6a1fc0c22
2335
2436
- 当你使用 ```System.exit()```
2537
- 其他线程干扰了现在运行的线程(通过 ```interrupt``` 方法)
2638
- 如果 JVM 已经“撞毁”了
2739

40+
<<<<<<< HEAD
2841
Answered by [Jodonnell](http://stackoverflow.com/users/4223/jodonnell), edited by [jpaugh](http://stackoverflow.com/users/712526/jpaugh).
2942

3043
2. //示例代码
44+
=======
45+
Answered by [Jodonnell](http://stackoverflow.com/users/4223/jodonnell),edited by [jpaugh](http://stackoverflow.com/users/712526/jpaugh).
46+
47+
2. //示例代码
48+
49+
>>>>>>> 28e7878b6828743ba520b991713ff3e6a1fc0c22
3150
``` java
3251
class Test
3352
{
@@ -47,12 +66,22 @@ class Test
4766
}
4867
}
4968
```
69+
<<<<<<< HEAD
5070
输出:
71+
=======
72+
输出:
73+
74+
>>>>>>> 28e7878b6828743ba520b991713ff3e6a1fc0c22
5175
``` java
5276
finally trumps return.
5377
0
5478
```
79+
<<<<<<< HEAD
5580
Answered by [Kevin](http://stackoverflow.com/users/1058366/kevin)
81+
=======
82+
83+
Answered by [Kevin](http://stackoverflow.com/users/1058366/kevin)
84+
>>>>>>> 28e7878b6828743ba520b991713ff3e6a1fc0c22
5685
5786
---
5887
原文链接:http://stackoverflow.com/questions/65035/does-finally-always-execute-in-java?page=1&tab=votes#tab-top

0 commit comments

Comments
 (0)
Please sign in to comment.