线程池定义-通用

package com.biaodian.xxljob.constant;

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

import com.google.common.util.concurrent.ThreadFactoryBuilder;

public class PoolConstant {
	
    public static final Integer INTEGER_ZERO = 0;
    public static final Integer INTEGER_ONE = 1, INTEGER_TWO = 2, INTEGER_THREE = 3, INTEGER_FIVE = 5, INTEGER_FOR = 4;
    public static final Integer INTEGER_TEN = 10, INTEGER_THIRTY= 30, INTEGER_FIFTY = 50;
    public static final Integer INTEGER_ONE_HUNDRED = 100, INTEGER_TWO_HUNDRED = 200, INTEGER_THREE_HUNDRED = 300, INTEGER_FIVE_HUNDRED = 500;
    public static final Integer INTEGER_ONE_THOUSAND = 1000, INTEGER_TEN_THOUSAND = 10000;
    public static final Long THREE_DAYS = 2592000000L;
	 /**
     * 线程池线程数
     */
    public static final int INIT_THREAD_POOL_SIZE = 32, DEFAULT_THREAD_POOL_SIZE = 32, MAX_THREAD_POOL_SIZE = 100;
    /**
     * 全局线程工厂
     */
    private static final ThreadFactory NAMED_THREAD_FACTORY = new ThreadFactoryBuilder().setNameFormat("tokens-pool-%d").build();
    /**
     * OKHTTP线程池
     */
    public static final ThreadPoolExecutor OKHTTP_THREAD_POOL = new ThreadPoolExecutor(INTEGER_ONE, INTEGER_ONE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_FOR), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());
//    /**
//     * 重试线程池
//     */
//    public static final ThreadPoolExecutor RETRY_THREAD_POOL = new ThreadPoolExecutor(INIT_THREAD_POOL_SIZE, INIT_THREAD_POOL_SIZE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.AbortPolicy());
    /**
     * 公共线程池
     */
    public static final ThreadPoolExecutor COMMON_THREAD_POOL = new ThreadPoolExecutor(INTEGER_ONE, INTEGER_ONE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_FOR), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());
    /**
     * 对账订单线程池
     */
    public static final ThreadPoolExecutor ORDER_THREAD_POOL = new ThreadPoolExecutor(INTEGER_FIVE, INTEGER_FIVE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());

    /**
     * 站点基本信息线程池
     */
    //public static final ThreadPoolExecutor SITE_THREAD_POOL = new ThreadPoolExecutor(INTEGER_TEN, INTEGER_TEN, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());
    public static final ThreadPoolExecutor SITE_THREAD_POOL = new ThreadPoolExecutor(INTEGER_FIVE, INTEGER_FIVE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());

    
    /**
     * 达人分析线程池
     */
    public static final ThreadPoolExecutor TALENT_THREAD_POOL = new ThreadPoolExecutor(INTEGER_ONE, INTEGER_ONE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());

    /**
     * 线程池为1
     */
    public static final ThreadPoolExecutor THREAD_INTEGER_ONE = new ThreadPoolExecutor(INTEGER_ONE, INTEGER_ONE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());

    /**
     * 线程池为5
     */
    public static final ThreadPoolExecutor THREAD_INTEGER_FIVE = new ThreadPoolExecutor(INTEGER_FIVE, INTEGER_FIVE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());

    /**
     * 线程池为10
     */
    public static final ThreadPoolExecutor THREAD_INTEGER_TEN = new ThreadPoolExecutor(INTEGER_TEN, INTEGER_TEN, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());

    /**
     * 线程池为30
     */
    public static final ThreadPoolExecutor THREAD_INTEGER_THIRTY = new ThreadPoolExecutor(INTEGER_THIRTY, INTEGER_THIRTY, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());

    /**
     * 拉取商品线程池
     */
//public static final ThreadPoolExecutor MATE_GOODS_INFO = new ThreadPoolExecutor(INTEGER_ONE, INTEGER_ONE, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());
public static final ThreadPoolExecutor MATE_GOODS_INFO = new ThreadPoolExecutor(6, 6, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(INTEGER_THIRTY), NAMED_THREAD_FACTORY, new ThreadPoolExecutor.CallerRunsPolicy());
//    /**
//     * 任务线程池
//     */
//    public static final ScheduledThreadPoolExecutor SCHEDULED_THREAD_POOL = new ScheduledThreadPoolExecutor(INIT_THREAD_POOL_SIZE, NAMED_THREAD_FACTORY);
//
//	

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值