1
zhanghua
2024-09-26 c775c6953d9759e70f08acbfa8f6d7490aaae3d1
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
package com.netsdk.demo.util;
 
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
 
/**
 * @author 291189
 * @version 1.0
 * @description
 * @date 2021/7/20 16:01
 */
public class ThreadPoolUtil {
 
        private static final int CORE_SIZE = 20;
 
        private static final int MAX_SIZE = 40;
 
        private static final long KEEP_ALIVE_TIME = 30;
 
        private static final int QUEUE_SIZE = 5000;
 
        private static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(CORE_SIZE, MAX_SIZE, KEEP_ALIVE_TIME,
                TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(QUEUE_SIZE), new ThreadPoolExecutor.AbortPolicy());
 
        public static ThreadPoolExecutor getThreadPool() {
            return threadPool;
 
    }
 
 
}