/
CatchError.java
62 lines (41 loc) · 1.12 KB
/
CatchError.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package handle;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import bean.User;
import bean.UserLoginLog;
import bean.UserRole;
import utils.Dao;
public class CatchError implements Runnable {
public static void main(String[] args) {
try {
int thread_count = 5;
int run_count = thread_count * 2;
ExecutorService executor = Executors.newFixedThreadPool(thread_count);
long start = System.currentTimeMillis();
for(int i=0;i<run_count;i++){
executor.execute(new CatchError());
}
executor.shutdown();
while (!executor.isTerminated()) {
}
long end = System.currentTimeMillis();
System.out.println(end - start);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void run() {
try {
long user_id = 1;
Dao dao = new Dao();
User user = dao.findUser(user_id);
List<UserRole> roles = dao.getUserRole(user_id);
List<UserLoginLog> loginList = dao.getUserLoginLog(user_id);
roles.get(100);
} catch (Exception e) {
e.printStackTrace();
}
}
}