类 Executors2
- java.lang.Object
-
- net.dongliu.commons.concurrent.Executors2
-
public class Executors2 extends java.lang.ObjectUtils methods for Executor
-
-
构造器概要
构造器 构造器 说明 Executors2()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static java.util.concurrent.ExecutorServicenewFixedThreadPool(int poolSize, int queueSize, java.lang.String threadNamePrefix)Create a new thread pool with fixed pool size, and max task queue size.static java.util.concurrent.ExecutorServicenewFixedThreadPool(int poolSize, int queueSize, java.util.concurrent.ThreadFactory threadFactory)Create a new thread pool with fixed pool size, and max task queue size.static java.util.concurrent.ExecutorServicenewFixedThreadPool(int poolSize, int queueSize, java.util.concurrent.ThreadFactory threadFactory, java.util.concurrent.RejectedExecutionHandler handler)Create a new thread pool with fixed pool size, and max task queue size.static java.util.concurrent.ScheduledFuture<?>scheduleAt(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable runnable, java.time.Instant instant)Schedule task at specific time.static <T> java.util.concurrent.ScheduledFuture<T>scheduleAt(java.util.concurrent.ScheduledExecutorService executor, java.util.concurrent.Callable<T> callable, java.time.Instant instant)Schedule task at specific time.static voidshutdownAndAwait(java.util.concurrent.ExecutorService executor, java.time.Duration timeout)Shutdown Executor and wait task finished.static ThreadPoolBuilderthreadPoolBuilder()Return a new ThreadPoolBuilder
-
-
-
方法详细资料
-
newFixedThreadPool
public static java.util.concurrent.ExecutorService newFixedThreadPool(int poolSize, int queueSize, java.lang.String threadNamePrefix)Create a new thread pool with fixed pool size, and max task queue size. When task queue is full, run task on current thread, this will block current thread, prevent from submitting more tasks. The Thread name are set as as pattern $threadNamePrefix-thread-$seq.- 参数:
poolSize- fixed pool sizequeueSize- max task queue sizethreadNamePrefix- the thread name prefix- 返回:
- ThreadPool
-
newFixedThreadPool
public static java.util.concurrent.ExecutorService newFixedThreadPool(int poolSize, int queueSize, java.util.concurrent.ThreadFactory threadFactory)Create a new thread pool with fixed pool size, and max task queue size. When task queue is full, run task on current thread, this will block current thread, prevent from submitting more tasks.- 参数:
poolSize- fixed pool sizequeueSize- max task queue sizethreadFactory- for create thread- 返回:
- ThreadPool
-
newFixedThreadPool
public static java.util.concurrent.ExecutorService newFixedThreadPool(int poolSize, int queueSize, java.util.concurrent.ThreadFactory threadFactory, java.util.concurrent.RejectedExecutionHandler handler)Create a new thread pool with fixed pool size, and max task queue size.- 参数:
poolSize- fixed pool sizequeueSize- max task queue sizethreadFactory- for create threadhandler- handler when queue is full- 返回:
- ThreadPool
-
threadPoolBuilder
public static ThreadPoolBuilder threadPoolBuilder()
Return a new ThreadPoolBuilder- 返回:
- ThreadPoolBuilder
-
shutdownAndAwait
public static void shutdownAndAwait(java.util.concurrent.ExecutorService executor, java.time.Duration timeout)Shutdown Executor and wait task finished.Previously submitted tasks are executed, but no new tasks will be accepted. This method blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first. If thread is interrupted, or timeout occurred, will stop all executing tasks by interrupt thread, and cancel all waiting tasks.
- 参数:
executor- the executor to terminatetimeout- the timeout duration to wait tasks finished.
-
scheduleAt
public static java.util.concurrent.ScheduledFuture<?> scheduleAt(java.util.concurrent.ScheduledExecutorService executor, java.lang.Runnable runnable, java.time.Instant instant)Schedule task at specific time. If the task's run time is already passed, schedule it right now.
-
scheduleAt
public static <T> java.util.concurrent.ScheduledFuture<T> scheduleAt(java.util.concurrent.ScheduledExecutorService executor, java.util.concurrent.Callable<T> callable, java.time.Instant instant)Schedule task at specific time. If the task's run time is already passed, schedule it right now.
-
-