admin
2021-12-04 c79b1ebed5a42a4cbb2f824232da2a51ff22a9a1
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
package com.yeshi.location.app.utils;
 
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
 
/**
 * @author hxh
 * @title: ThreadUtil
 * @description: TODO
 * @date 2021/12/2 17:50
 */
public class ThreadUtil {
 
    private static LinkedBlockingQueue<Runnable> queue=new LinkedBlockingQueue<Runnable>(100);
 
    private static ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(30, 3000, 20, TimeUnit.SECONDS, queue);
 
    static{
        threadPoolExecutor.allowCoreThreadTimeOut(true);
    }
 
    public static void run(Runnable runnable){
        threadPoolExecutor.execute(runnable);
    }
 
}