Class ExecutorKit
java.lang.Object
com.iohao.net.common.kit.concurrent.ExecutorKit
Thread executor factory utilities.
- Author:
- 渔民小镇
- date:
- 2021-12-20
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateSigleThreadFactory(@NonNull String name) Create a single-named daemon thread factory.createThreadFactory(@NonNull String namePrefix, boolean daemon) Create a thread factory.createThreadFactory(String namePrefix) Create a thread factory.newCacheThreadPool(String namePrefix) Create a cached thread pool.newCacheThreadPool(ThreadFactory threadFactory) Create a cached thread pool.newFixedThreadPool(int corePoolSize, String namePrefix) Create a fixed-size thread pool.newFixedThreadPool(int corePoolSize, ThreadFactory threadFactory) Create a fixed-size thread pool.newScheduled(int corePoolSize, String namePrefix) Create a scheduled executor with the specified pool size.newScheduled(int corePoolSize, ThreadFactory threadFactory) Create a scheduled executor with the specified pool size.newSingleScheduled(String namePrefix) Create a single-thread scheduled executor.newSingleScheduled(ThreadFactory threadFactory) Create a single-thread scheduled executor.newSingleThreadExecutor(String namePrefix) Create a single-thread executor.newSingleThreadExecutor(ThreadFactory threadFactory) Create a single-thread executor.newVirtualExecutor(String name) Create a virtual thread executor.newVirtualExecutor(String name, int start) Create a virtual thread executor.newVirtualExecutor(ThreadFactory factory) Create a virtual thread executor.
-
Constructor Details
-
ExecutorKit
public ExecutorKit()
-
-
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
-