Skip to content

Commit 5c27bf2

Browse files
committed
添加多线程第二章知识点总结
1 parent d5d5506 commit 5c27bf2

6 files changed

Lines changed: 607 additions & 18 deletions

File tree

pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
<groupId>cn.byhieg</groupId>
88
<artifactId>javaturorial</artifactId>
99
<version>0.1</version>
10+
<build>
11+
<plugins>
12+
<plugin>
13+
<groupId>org.apache.maven.plugins</groupId>
14+
<artifactId>maven-compiler-plugin</artifactId>
15+
<configuration>
16+
<source>1.8</source>
17+
<target>1.8</target>
18+
</configuration>
19+
</plugin>
20+
</plugins>
21+
</build>
1022

1123
<properties>
1224
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package cn.byhieg.threadtutorial.char02;
2+
3+
import java.io.*;
4+
5+
/**
6+
* Created by byhieg on 17/1/5.
7+
* Mail to byhieg@gmail.com
8+
*/
9+
public class ExceptionService {
10+
11+
synchronized public void getFile(){
12+
System.out.println("begin " + System.currentTimeMillis() + " " + Thread.currentThread().getName());
13+
File file = new File("111");
14+
try {
15+
Thread.sleep(1000 * 1);
16+
System.out.println(5 / 0);
17+
InputStream in = new FileInputStream(file);
18+
System.out.println("end" + System.currentTimeMillis() + " " + Thread.currentThread().getName());
19+
20+
} catch (FileNotFoundException | InterruptedException e) {
21+
try {
22+
Thread.sleep(1000);
23+
} catch (InterruptedException e1) {
24+
e1.printStackTrace();
25+
}
26+
System.out.println("end Catch" + System.currentTimeMillis() + " " + Thread.currentThread().getName());
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)