package com.zkqy.system.test;

import java.util.concurrent.*;

public class DatabaseService {
    private static ExecutorService executorService;
    private static BlockingQueue<Runnable> taskQueue;

    static {
        int corePoolSize = 10; // 核心线程数
        int maximumPoolSize = 20; // 最大线程数
        long keepAliveTime = 5000; // 空闲线程等待新任务的最长时间（毫秒）
        int queueCapacity = 500; // 任务队列容量
        taskQueue = new LinkedBlockingQueue<>(queueCapacity);
        executorService = new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, taskQueue);
    }

    public static void executeTask(Runnable task) {
        executorService.execute(task);
    }
}