Class ExecutorKit
java.lang.Object
com.iohao.net.common.kit.concurrent.ExecutorKit
Thread executor factory utilities.
- Author:
- 渔民小镇
- date:
- 2021-12-20
-
Method Summary
Modifier and TypeMethodDescriptionstatic ThreadFactorycreateSigleThreadFactory(@NonNull String name) Create a single-named daemon thread factory.static ThreadFactorycreateThreadFactory(@NonNull String namePrefix, boolean daemon) Create a thread factory.static ThreadFactorycreateThreadFactory(String namePrefix) Create a thread factory.static ExecutorServicenewCacheThreadPool(String namePrefix) Create a cached thread pool.static ExecutorServicenewCacheThreadPool(ThreadFactory threadFactory) Create a cached thread pool.static ExecutorServicenewFixedThreadPool(int corePoolSize, String namePrefix) Create a fixed-size thread pool.static ExecutorServicenewFixedThreadPool(int corePoolSize, ThreadFactory threadFactory) Create a fixed-size thread pool.static ScheduledExecutorServicenewScheduled(int corePoolSize, String namePrefix) Create a scheduled executor with the specified pool size.static ScheduledExecutorServicenewScheduled(int corePoolSize, ThreadFactory threadFactory) Create a scheduled executor with the specified pool size.static ScheduledExecutorServicenewSingleScheduled(String namePrefix) Create a single-thread scheduled executor.static ScheduledExecutorServicenewSingleScheduled(ThreadFactory threadFactory) Create a single-thread scheduled executor.static ExecutorServicenewSingleThreadExecutor(String namePrefix) Create a single-thread executor.static ExecutorServicenewSingleThreadExecutor(ThreadFactory threadFactory) Create a single-thread executor.static ExecutorServicenewVirtualExecutor(String name) Create a virtual thread executor.static ExecutorServicenewVirtualExecutor(String name, int start) Create a virtual thread executor.static ExecutorServicenewVirtualExecutor(ThreadFactory factory) Create a virtual thread executor.
-
Method Details
-
newVirtualExecutor
Create a virtual thread executor.- Parameters:
name- thread name prefix- Returns:
- the virtual thread executor
-
newVirtualExecutor
Create a virtual thread executor.- Parameters:
name- thread name prefixstart- starting value for the thread name counter- Returns:
- the virtual thread executor
-
newVirtualExecutor
Create a virtual thread executor.- Parameters:
factory- thread factory for virtual threads- Returns:
- the virtual thread executor
-
newSingleThreadExecutor
Create a single-thread executor.- Parameters:
namePrefix- thread name prefix- Returns:
- the single-thread executor
-
newSingleThreadExecutor
Create a single-thread executor.- Parameters:
threadFactory- thread factory- Returns:
- the single-thread executor
-
newCacheThreadPool
Create a cached thread pool.- Parameters:
namePrefix- thread name prefix- Returns:
- the cached thread pool executor
-
newCacheThreadPool
Create a cached thread pool.- Parameters:
threadFactory- thread factory- Returns:
- the cached thread pool executor
-
newFixedThreadPool
Create a fixed-size thread pool.- Parameters:
corePoolSize- pool sizethreadFactory- thread factory- Returns:
- the fixed-size thread pool executor
-
newFixedThreadPool
Create a fixed-size thread pool.- Parameters:
corePoolSize- pool sizenamePrefix- thread name prefix- Returns:
- the fixed-size thread pool executor
-
newSingleScheduled
Create a single-thread scheduled executor.- Parameters:
threadFactory- thread factory- Returns:
- the single-thread scheduled executor
-
newSingleScheduled
Create a single-thread scheduled executor.- Parameters:
namePrefix- thread name prefix- Returns:
- the single-thread scheduled executor
-
newScheduled
Create a scheduled executor with the specified pool size.- Parameters:
corePoolSize- pool sizenamePrefix- thread name prefix- Returns:
- the scheduled executor
-
newScheduled
Create a scheduled executor with the specified pool size.- Parameters:
corePoolSize- pool sizethreadFactory- thread factory- Returns:
- the scheduled executor
-
createThreadFactory
Create a thread factory. Daemon is true by default.- Parameters:
namePrefix- thread name prefix- Returns:
- the thread factory
-
createThreadFactory
Create a thread factory.- Parameters:
namePrefix- thread name prefixdaemon- whether threads are daemon threads- Returns:
- the thread factory
-
createSigleThreadFactory
Create a single-named daemon thread factory.- Parameters:
name- the fixed thread name- Returns:
- the thread factory
-