admin
2024-09-05 ab35ac8b769b2d9816dffb33a64f2c6f7bd5dd6e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.yeshi.buwan.util;
 
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
 
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);
    }
}