admin
2019-07-22 b4b421ba6b85b586f9b8171c876f716bab9840d0
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
package com.yeshi.fanli.util;
 
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
 * 线程池工具
 * @author cxx
 *
 * @date 2018年1月29日
 */
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);
    }
    
}