public abstract class BaseLocalThreadPool extends Object
用于创建和获取线程池的类,是一个线程池工厂
虽然是个抽象类却没有抽象方法,主要用于继承
可以直接使用set对各种参数进行设置,set的参数为每一次创建线程池的时候使用的配置信息
内部使用map集合实现线程池
Modifier and Type | Class and Description |
---|---|
static class |
BaseLocalThreadPool.PoolConfig
配置类,提供几个参数
|
Constructor and Description |
---|
BaseLocalThreadPool() |
Modifier and Type | Method and Description |
---|---|
static int |
getCorePoolSize() |
static ThreadFactory |
getFactory()
获取线程工厂
|
static long |
getKeepAliveTime() |
static Executor |
getLocalThreadPool()
获取本线程中的线程池
|
static int |
getMaximumPoolSize() |
static Executor |
getThreadPool()
创建线程池的工厂,无名称,使用默认
|
static Executor |
getThreadPool(BaseLocalThreadPool.PoolConfig poolConfig)
创建线程池的工厂,无名称,使用默认
|
static ExecutorService |
getThreadPool(String poolName)
创建线程池的工厂
|
static Executor |
getThreadPool(String poolName,
BaseLocalThreadPool.PoolConfig poolConfig)
创建线程池的工厂
|
static TimeUnit |
getTimeUnit() |
static BlockingQueue<Runnable> |
getWorkQueue() |
static boolean |
removeLocalThreadPool()
Deprecated.
|
static boolean |
removeThreadPool(String poolName)
清除某指定的线程池
|
static void |
setCorePoolSize(int corePoolSize)
Deprecated.
|
static void |
setDefaultThreadFactory(ThreadFactory defaultThreadFactory)
Deprecated.
|
static void |
setKeepAliveTime(long keepAliveTime)
Deprecated.
|
static void |
setMaximumPoolSize(int maximumPoolSize)
Deprecated.
|
static void |
setTimeUnit(TimeUnit timeUnit)
Deprecated.
|
static void |
setWorkQueue(BlockingQueue<Runnable> workQueue)
Deprecated.
|
public static ExecutorService getThreadPool(String poolName)
poolName
- 创建的线程池的名称public static Executor getThreadPool()
public static Executor getThreadPool(String poolName, BaseLocalThreadPool.PoolConfig poolConfig)
poolName
- 创建的线程池的名称public static Executor getThreadPool(BaseLocalThreadPool.PoolConfig poolConfig)
public static boolean removeThreadPool(String poolName)
poolName
- public static Executor getLocalThreadPool()
@Deprecated public static boolean removeLocalThreadPool()
public static ThreadFactory getFactory()
public static int getCorePoolSize()
@Deprecated public static void setCorePoolSize(int corePoolSize)
public static int getMaximumPoolSize()
@Deprecated public static void setMaximumPoolSize(int maximumPoolSize)
public static long getKeepAliveTime()
@Deprecated public static void setKeepAliveTime(long keepAliveTime)
public static TimeUnit getTimeUnit()
@Deprecated public static void setTimeUnit(TimeUnit timeUnit)
timeUnit
- 时间类型public static BlockingQueue<Runnable> getWorkQueue()
@Deprecated public static void setWorkQueue(BlockingQueue<Runnable> workQueue)
@Deprecated public static void setDefaultThreadFactory(ThreadFactory defaultThreadFactory)
defaultThreadFactory
- 线程工厂Copyright © 2020. All rights reserved.