public class ExtensibleThreadPoolExecutor extends ThreadPoolExecutor implements ThreadPoolPluginSupport
Extensible thread-pool executor.
Support the callback extension points provided on the basis of ThreadPoolExecutor.
Each extension point corresponds to a different ThreadPoolPlugin interface,
users can customize plug-ins and implement one or more ThreadPoolPlugin interface
to enable plugins to sense thread pool behavior and provide extended functions.
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| 构造器和说明 |
|---|
ExtensibleThreadPoolExecutor(@NonNull String threadPoolId,
@NonNull ThreadPoolPluginManager threadPoolPluginManager,
int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
@NonNull BlockingQueue<Runnable> workQueue,
@NonNull ThreadFactory threadFactory,
@NonNull RejectedExecutionHandler handler)
Creates a new
ExtensibleThreadPoolExecutor with the given initial parameters. |
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setThreadFactory, toStringinvokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submitclear, getAllPlugins, getExecuteAwarePluginList, getPlugin, getRejectedAwarePluginList, getShutdownAwarePluginList, getTaskAwarePluginList, getThreadPoolId, getThreadPoolPluginManager, isRegistered, register, tryRegister, unregisterempty, getAllPluginRuntimes, getAllPluginsOfType, getPluginOfType, getRuntimepublic ExtensibleThreadPoolExecutor(@NonNull
@NonNull String threadPoolId,
@NonNull
@NonNull ThreadPoolPluginManager threadPoolPluginManager,
int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
@NonNull
@NonNull BlockingQueue<Runnable> workQueue,
@NonNull
@NonNull ThreadFactory threadFactory,
@NonNull
@NonNull RejectedExecutionHandler handler)
ExtensibleThreadPoolExecutor with the given initial parameters.threadPoolId - thread-pool idthreadPoolPluginManager - action aware registrycorePoolSize - the number of threads to keep in the pool, even
if they are idle, unless allowCoreThreadTimeOut is setmaximumPoolSize - the maximum number of threads to allow in the
poolkeepAliveTime - when the number of threads is greater than
the core, this is the maximum time that excess idle threads
will wait for new tasks before terminating.unit - the time unit for the keepAliveTime argumentworkQueue - the queue to use for holding tasks before they are
executed. This queue will hold only the Runnable
tasks submitted by the execute method.threadFactory - the factory to use when the executor
creates a new threadhandler - the handler to use when execution is blocked
because the thread bounds and queue capacities are reachedIllegalArgumentException - if one of the following holds:corePoolSize < 0keepAliveTime < 0maximumPoolSize <= 0maximumPoolSize < corePoolSizeNullPointerException - if workQueue
or threadFactory or handler is nullprotected void beforeExecute(Thread thread, Runnable runnable)
Before calling the parent class method, ExecuteAwarePlugin.beforeExecute(java.lang.Thread, java.lang.Runnable) will be called first.
beforeExecute 在类中 ThreadPoolExecutorthread - the thread that will run task rrunnable - the task that will be executedpublic void execute(@NonNull
@NonNull Runnable runnable)
Before calling the superclass method, TaskAwarePlugin.beforeTaskExecute(java.lang.Runnable) will be called first.
execute 在接口中 Executorexecute 在类中 ThreadPoolExecutorrunnable - the task to executeprotected void afterExecute(Runnable runnable, Throwable throwable)
After calling the superclass method, ExecuteAwarePlugin.afterExecute(java.lang.Runnable, java.lang.Throwable) will be called last.
afterExecute 在类中 ThreadPoolExecutorrunnable - the runnable that has completedthrowable - the exception that caused termination, or null if
execution completed normallypublic void shutdown()
Before calling the superclass method,
ShutdownAwarePlugin.beforeShutdown(java.util.concurrent.ThreadPoolExecutor) will be called first.
and then will be call ShutdownAwarePlugin.afterShutdown(java.util.concurrent.ThreadPoolExecutor, java.util.List<java.lang.Runnable>)
shutdown 在接口中 ExecutorServiceshutdown 在类中 ThreadPoolExecutorSecurityExceptionpublic List<Runnable> shutdownNow()
Before calling the superclass method,
ShutdownAwarePlugin.beforeShutdown(java.util.concurrent.ThreadPoolExecutor) will be called first.
and then will be call ShutdownAwarePlugin.afterShutdown(java.util.concurrent.ThreadPoolExecutor, java.util.List<java.lang.Runnable>)
shutdownNow 在接口中 ExecutorServiceshutdownNow 在类中 ThreadPoolExecutorSecurityExceptionprotected void terminated()
Before calling the superclass method, ShutdownAwarePlugin.afterTerminated(cn.hippo4j.core.executor.ExtensibleThreadPoolExecutor) will be called first.
terminated 在类中 ThreadPoolExecutorprotected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
Before calling the superclass method, TaskAwarePlugin.beforeTaskCreate(java.util.concurrent.ThreadPoolExecutor, java.lang.Runnable, V) will be called first.
newTaskFor 在类中 AbstractExecutorServicerunnable - the runnable task being wrappedvalue - the default value for the returned futureRunnableFuture which, when run, will run the
underlying runnable and which, as a Future, will yield
the given value as its result and provide for cancellation of
the underlying taskprotected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
Before calling the superclass method, TaskAwarePlugin.beforeTaskCreate(java.util.concurrent.ThreadPoolExecutor, java.lang.Runnable, V) will be called first.
newTaskFor 在类中 AbstractExecutorServicecallable - the callable task being wrappedRunnableFuture which, when run, will call the
underlying callable and which, as a Future, will yield
the callable's result as its result and provide for
cancellation of the underlying taskpublic void setRejectedExecutionHandler(@NonNull
@NonNull RejectedExecutionHandler handler)
setRejectedExecutionHandler 在类中 ThreadPoolExecutorhandler - the new handlerNullPointerException - if handler is nullgetRejectedExecutionHandler()public RejectedExecutionHandler getRejectedExecutionHandler()
getRejectedExecutionHandler 在类中 ThreadPoolExecutorsetRejectedExecutionHandler(RejectedExecutionHandler)public ThreadPoolExecutor getThreadPoolExecutor()
getThreadPoolExecutor 在接口中 ThreadPoolPluginSupportCopyright © 2022. All rights reserved.