package com.sckw.payment.job;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author xucaiqin
 * @date 2023-09-05 20:13:57
 */
public class AsyncPool {

    private AsyncPool() {
    }

    /**
     * 提交任务
     *
     * @param runnable
     */
    public static void addTask(Runnable runnable) {
        ThreadPool.threadPoolExecutor.execute(runnable);
    }

    private static class ThreadPool {
        public static final ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors() / 2,
                Runtime.getRuntime().availableProcessors() / 2 + 1,
                1,
                TimeUnit.MINUTES,
                new LinkedBlockingQueue<>(12));

    }
}
