35 lines
741 B
Java
35 lines
741 B
Java
package com.muyu.web.common.pool;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Future;
|
|
|
|
/**
|
|
* @author DongZl
|
|
* @description: 可控最大并发数线程池
|
|
* @Date 2023-12-5 下午 01:51
|
|
*/
|
|
public class FixedThreadPool {
|
|
|
|
/**
|
|
* 可重用固定个数的线程池
|
|
*/
|
|
private final static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(15);
|
|
|
|
|
|
/**
|
|
* 线程池提交任务
|
|
* @param thread 线程
|
|
*/
|
|
public static Future<?> submit(Thread thread){
|
|
return fixedThreadPool.submit(thread);
|
|
}
|
|
|
|
/**
|
|
* 关闭线程池
|
|
*/
|
|
public static void shutDown(){
|
|
fixedThreadPool.shutdown();
|
|
}
|
|
}
|