All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.twitch4j.common.util.ThreadUtils Maven / Gradle / Ivy

There is a newer version: 1.23.0
Show newest version
package com.github.twitch4j.common.util;

import org.apache.commons.lang3.concurrent.BasicThreadFactory;

import java.util.concurrent.ScheduledThreadPoolExecutor;

public class ThreadUtils {

    /**
     * The default thread pool executor used in twitch4j
     * 

* PubSub: 2 Thread(s) * Chat: 1 Thread(s) * ClientHelper: 2 Thread(s) * * @return ScheduledThreadPoolExecutor */ public static ScheduledThreadPoolExecutor getDefaultScheduledThreadPoolExecutor(String namePrefix, Integer poolSize) { BasicThreadFactory threadFactory = new BasicThreadFactory.Builder() .namingPattern(namePrefix+"-%d") .daemon(false) .priority(Thread.NORM_PRIORITY) .build(); ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(poolSize); scheduledThreadPoolExecutor.setThreadFactory(threadFactory); scheduledThreadPoolExecutor.setRemoveOnCancelPolicy(true); return scheduledThreadPoolExecutor; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy