-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecutorBasicMain.java
More file actions
33 lines (26 loc) · 1.09 KB
/
Copy pathExecutorBasicMain.java
File metadata and controls
33 lines (26 loc) · 1.09 KB
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
package thread.executor;
import util.MyLogger;
import util.ThreadUtils;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class ExecutorBasicMain {
public static void main(String[] args) {
ExecutorService es = new ThreadPoolExecutor(2,2,0, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>());
MyLogger.log("============초기상태============");
ExecutorUtils.printState(es);
es.execute(new RunnableTask("tastA"));
es.execute(new RunnableTask("tastB"));
es.execute(new RunnableTask("tastC"));
es.execute(new RunnableTask("tastD"));
MyLogger.log("============수행 중============");
ExecutorUtils.printState(es);
ThreadUtils.sleep(3000);
MyLogger.log("============작업 수행 완료============");
ExecutorUtils.printState(es);
es.shutdownNow();
MyLogger.log("============shutdown 완료============");
ExecutorUtils.printState(es);
}
}