Package org.jgroups.util
Class ThreadPool
- java.lang.Object
-
- org.jgroups.util.ThreadPool
-
-
Field Summary
Fields Modifier and Type Field Description protected Addressaddressprotected intdeltaprotected booleanenabledprotected booleanincrease_max_size_dynamicallyprotected longkeep_alive_timeprotected Loglogprotected intmax_threadsprotected intmin_threadsprotected java.util.concurrent.atomic.LongAddernum_rejected_msgsprotected java.util.concurrent.RejectedExecutionHandlerrejected_handlerprotected java.lang.Stringrejection_policyprotected java.lang.Stringthread_dump_pathDeprecated.protected booleanthread_dumps_enabledprotected intthread_dumps_thresholdDeprecated.protected ThreadFactorythread_factoryprotected java.util.concurrent.Executorthread_poolprotected SuppressLog<java.lang.String>thread_pool_full_logprotected longthread_pool_full_suppress_time
-
Constructor Summary
Constructors Constructor Description ThreadPool()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static java.util.concurrent.ExecutorServicecreateThreadPool(int min_threads, int max_threads, long keep_alive_time, java.lang.String rejection_policy, java.util.concurrent.BlockingQueue<java.lang.Runnable> queue, ThreadFactory factory, Log log)voiddestroy()Called after an instance has been stopped.voiddoExecute(java.lang.Runnable task)booleanexecute(java.lang.Runnable task)booleanexecute(java.lang.Runnable task, java.util.concurrent.RejectedExecutionHandler h)AddressgetAddress()intgetDelta()booleangetIncreaseMaxSizeDynamically()longgetKeepAliveTime()intgetLargestSize()intgetMaxThreads()intgetMinThreads()protected static java.lang.invoke.MethodHandlegetNewThreadPerTaskExecutorHandle()static intgetNumberOfThreadDumps()Deprecated.java.util.concurrent.RejectedExecutionHandlergetRejectedExecutionHandler()booleangetThreadDumpsEnabled()static intgetThreadDumpsThreshold()Deprecated.ThreadFactorygetThreadFactory()java.util.concurrent.ExecutorgetThreadPool()longgetThreadPoolFullSuppressTime()intgetThreadPoolSize()intgetThreadPoolSizeActive()voidinit()Called after an instance has been created and before it is started.booleanisEnabled()booleanisShutdown()ThreadPoollog(Log l)protected static java.util.concurrent.ExecutorServicenewVirtualThreadPool(ThreadFactory factory)longnumberOfRejectedMessages()java.util.concurrent.Executorpool()ThreadPoolremoveExpired()voidresetStats()voidresetThreadDumps()Deprecated.ThreadPoolsetAddress(Address a)ThreadPoolsetDelta(int d)ThreadPoolsetIncreaseMaxSizeDynamically(boolean b)ThreadPoolsetKeepAliveTime(long time)ThreadPoolsetMaxThreads(int size)ThreadPoolsetMinThreads(int size)voidsetRejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler handler)ThreadPoolsetRejectionPolicy(java.lang.String policy)ThreadPoolsetThreadDumpsEnabled(boolean b)ThreadPoolsetThreadDumpsThreshold(int ignore)Deprecated.ThreadPoolsetThreadFactory(ThreadFactory factory)ThreadPoolsetThreadPool(java.util.concurrent.Executor thread_pool)ThreadPoolsetThreadPoolFullSuppressTime(long t)java.lang.StringtoString()
-
-
-
Field Detail
-
thread_pool
protected java.util.concurrent.Executor thread_pool
-
log
protected Log log
-
thread_factory
protected ThreadFactory thread_factory
-
address
protected Address address
-
thread_pool_full_log
protected SuppressLog<java.lang.String> thread_pool_full_log
-
enabled
protected boolean enabled
-
min_threads
protected int min_threads
-
max_threads
protected int max_threads
-
keep_alive_time
protected long keep_alive_time
-
rejection_policy
protected java.lang.String rejection_policy
-
thread_pool_full_suppress_time
protected long thread_pool_full_suppress_time
-
thread_dumps_threshold
@Deprecated(since="5.4") protected int thread_dumps_threshold
Deprecated.
-
thread_dump_path
@Deprecated(since="5.4") protected java.lang.String thread_dump_path
Deprecated.
-
thread_dumps_enabled
protected boolean thread_dumps_enabled
-
increase_max_size_dynamically
protected boolean increase_max_size_dynamically
-
delta
protected int delta
-
num_rejected_msgs
protected final java.util.concurrent.atomic.LongAdder num_rejected_msgs
-
rejected_handler
protected final java.util.concurrent.RejectedExecutionHandler rejected_handler
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
-
getThreadPool
public java.util.concurrent.Executor getThreadPool()
-
setThreadPool
public ThreadPool setThreadPool(java.util.concurrent.Executor thread_pool)
-
setThreadFactory
public ThreadPool setThreadFactory(ThreadFactory factory)
-
getThreadFactory
public ThreadFactory getThreadFactory()
-
isShutdown
public boolean isShutdown()
-
getMinThreads
public int getMinThreads()
-
setMinThreads
public ThreadPool setMinThreads(int size)
-
getMaxThreads
public int getMaxThreads()
-
setMaxThreads
public ThreadPool setMaxThreads(int size)
-
getKeepAliveTime
public long getKeepAliveTime()
-
setKeepAliveTime
public ThreadPool setKeepAliveTime(long time)
-
setRejectionPolicy
public ThreadPool setRejectionPolicy(java.lang.String policy)
-
getRejectedExecutionHandler
public java.util.concurrent.RejectedExecutionHandler getRejectedExecutionHandler()
-
setRejectedExecutionHandler
public void setRejectedExecutionHandler(java.util.concurrent.RejectedExecutionHandler handler)
-
getThreadPoolFullSuppressTime
public long getThreadPoolFullSuppressTime()
-
setThreadPoolFullSuppressTime
public ThreadPool setThreadPoolFullSuppressTime(long t)
-
getThreadDumpsEnabled
public boolean getThreadDumpsEnabled()
-
setThreadDumpsEnabled
public ThreadPool setThreadDumpsEnabled(boolean b)
-
getAddress
public Address getAddress()
-
setAddress
public ThreadPool setAddress(Address a)
-
getIncreaseMaxSizeDynamically
public boolean getIncreaseMaxSizeDynamically()
-
setIncreaseMaxSizeDynamically
public ThreadPool setIncreaseMaxSizeDynamically(boolean b)
-
getDelta
public int getDelta()
-
setDelta
public ThreadPool setDelta(int d)
-
numberOfRejectedMessages
public long numberOfRejectedMessages()
-
log
public ThreadPool log(Log l)
-
getThreadDumpsThreshold
@Deprecated public static int getThreadDumpsThreshold()
Deprecated.
-
setThreadDumpsThreshold
@Deprecated public ThreadPool setThreadDumpsThreshold(int ignore)
Deprecated.
-
getNumberOfThreadDumps
@Deprecated public static int getNumberOfThreadDumps()
Deprecated.
-
resetThreadDumps
@Deprecated public void resetThreadDumps()
Deprecated.
-
getThreadPoolSize
public int getThreadPoolSize()
-
getThreadPoolSizeActive
public int getThreadPoolSizeActive()
-
getLargestSize
public int getLargestSize()
-
resetStats
public void resetStats()
-
init
public void init() throws java.lang.ExceptionDescription copied from interface:LifecycleCalled after an instance has been created and before it is started.
-
destroy
public void destroy()
Description copied from interface:LifecycleCalled after an instance has been stopped. Cleans up resources
-
removeExpired
public ThreadPool removeExpired()
-
doExecute
public void doExecute(java.lang.Runnable task)
-
pool
public java.util.concurrent.Executor pool()
-
execute
public boolean execute(java.lang.Runnable task, java.util.concurrent.RejectedExecutionHandler h)
-
execute
public boolean execute(java.lang.Runnable task)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
createThreadPool
protected static java.util.concurrent.ExecutorService createThreadPool(int min_threads, int max_threads, long keep_alive_time, java.lang.String rejection_policy, java.util.concurrent.BlockingQueue<java.lang.Runnable> queue, ThreadFactory factory, Log log)
-
newVirtualThreadPool
protected static java.util.concurrent.ExecutorService newVirtualThreadPool(ThreadFactory factory)
-
getNewThreadPerTaskExecutorHandle
protected static java.lang.invoke.MethodHandle getNewThreadPerTaskExecutorHandle()
-
-