- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFixedThreadPool.java
More file actions
Latest commit
38 lines (19 loc) · 713 Bytes
/
Copy pathFixedThreadPool.java
File metadata and controls
38 lines (19 loc) · 713 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
30
31
32
33
34
35
36
37
38
importjava.util.concurrent.ExecutorService;
importjava.util.concurrent.Executors;
publicclassFixedThreadPool {
publicstaticvoidmain(String[] args) {
ExecutorServiceexecutorService = Executors.newFixedThreadPool(4);
for(inti=0;i<7;i++){
Threadthread =newThread(()->{
System.out.println(Thread.currentThread().getName());
});
thread.start();
}
for(inti=0;i<10;i++){
Threadthread=newThread(()->{
System.out.println(Thread.currentThread().getName());
});
executorService.execute(thread);
}
}
}