forked from guangxush/wheel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainTask.java
More file actions
29 lines (24 loc) · 853 Bytes
/
Copy pathMainTask.java
File metadata and controls
29 lines (24 loc) · 853 Bytes
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
package submittask;
/**
* @author: guangxush
* @create: 2020/11/29
*/
public class MainTask {
private static SubmitRunnableTask submitRunnableTask = new SubmitRunnableTask();
private static SubmitCallableTask submitCallableTask = new SubmitCallableTask();
private static SubmitCallableUnBlockTask submitCallableUnBlockTask = new SubmitCallableUnBlockTask();
public static void main(String[] args) {
// 提交异步任务,这个不会抛异常
for(int i=0;i<10;i++){
submitCallableTask.execute();
}
// 同时提交10个任务,肯定会抛异常
for(int i=0;i<10;i++){
submitRunnableTask.execute();
}
// 同时提交10个任务,异步打印结果
for(int i=0;i<10;i++){
submitCallableUnBlockTask.execute();
}
}
}