Package org.apache.sling.commons.threads
Class ModifiableThreadPoolConfig
- java.lang.Object
-
- org.apache.sling.commons.threads.ModifiableThreadPoolConfig
-
- All Implemented Interfaces:
ThreadPoolConfig
@ProviderType public final class ModifiableThreadPoolConfig extends java.lang.Object implements ThreadPoolConfig
This is a modifiable thread pool configuration that can be instantiated and then configured to create a new thread pool. The default values for this configuration are: - min pool size: 5 - max pool size: 5 - queue size: -1 - keep alive time: 60000 - block policy: RUN - shutdown graceful: true - shutdown wait time: -1 - priority: NORM - daemon: false - factory: null (= default jvm thread factory)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sling.commons.threads.ThreadPoolConfig
ThreadPoolConfig.ThreadPoolPolicy, ThreadPoolConfig.ThreadPriority
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROPERTY_BLOCK_POLICY
Configuration property for the block policy.static java.lang.String
PROPERTY_DAEMON
Configuration property for the daemon flag.static java.lang.String
PROPERTY_KEEP_ALIVE_TIME
Configuration property for the keep alive time.static java.lang.String
PROPERTY_MAX_POOL_SIZE
Configuration property for the max pool size.static java.lang.String
PROPERTY_MAX_THREAD_AGE
Configuration property for the max thread age.static java.lang.String
PROPERTY_MIN_POOL_SIZE
Configuration property for the min pool size.static java.lang.String
PROPERTY_NAME
Configuration property for the thread pool name.static java.lang.String
PROPERTY_PRIORITY
Configuration property for the priority.static java.lang.String
PROPERTY_QUEUE_SIZE
Configuration property for the queue size.static java.lang.String
PROPERTY_SHUTDOWN_GRACEFUL
Configuration property for the shutdown graceful flag.static java.lang.String
PROPERTY_SHUTDOWN_WAIT_TIME
Configuration property for the shutdown wait time.
-
Constructor Summary
Constructors Constructor Description ModifiableThreadPoolConfig()
Create a new default configuration.ModifiableThreadPoolConfig(ThreadPoolConfig copy)
Clone an existing configuration
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
ThreadPoolConfig.ThreadPoolPolicy
getBlockPolicy()
Return the block policy.java.util.concurrent.ThreadFactory
getFactory()
Return the thread pool factory.long
getKeepAliveTime()
Return the keep alive time.int
getMaxPoolSize()
Return the maximum pool sizelong
getMaxThreadAge()
Return the maximum age before a thread is retired.int
getMinPoolSize()
Return the minimum pool size.ThreadPoolConfig.ThreadPriority
getPriority()
Return the priority for the threads.int
getQueueSize()
Return the queue size.int
getShutdownWaitTimeMs()
Return the shutdown wait time in ms.int
hashCode()
boolean
isDaemon()
Return if daemon threads should be created.boolean
isShutdownGraceful()
Should this pool shutdown graceful.void
setBlockPolicy(ThreadPoolConfig.ThreadPoolPolicy blockPolicy)
Set the block policy.void
setDaemon(boolean isDaemon)
Set the daemon handling.void
setFactory(java.util.concurrent.ThreadFactory factory)
Set the thread factory.void
setKeepAliveTime(long keepAliveTime)
Set the keep alive time.void
setMaxPoolSize(int maxPoolSize)
Set the max pool size.void
setMaxThreadAge(long maxThreadAge)
Deprecated.Since version 3.4.0 should no longer be called, as threads are no longer retired but instead the thread locals are cleaned up (SLING-6261)void
setMinPoolSize(int minPoolSize)
Set the min pool size.void
setPriority(ThreadPoolConfig.ThreadPriority priority)
Set the thread priority.void
setQueueSize(int queueSize)
Set the queue size.void
setShutdownGraceful(boolean shutdownGraceful)
Set if the pool should be shutdown graceful.void
setShutdownWaitTimeMs(int shutdownWaitTimeMs)
Set the shutdown wait time.
-
-
-
Field Detail
-
PROPERTY_MIN_POOL_SIZE
public static final java.lang.String PROPERTY_MIN_POOL_SIZE
Configuration property for the min pool size.- See Also:
- Constant Field Values
-
PROPERTY_MAX_POOL_SIZE
public static final java.lang.String PROPERTY_MAX_POOL_SIZE
Configuration property for the max pool size.- See Also:
- Constant Field Values
-
PROPERTY_QUEUE_SIZE
public static final java.lang.String PROPERTY_QUEUE_SIZE
Configuration property for the queue size.- See Also:
- Constant Field Values
-
PROPERTY_MAX_THREAD_AGE
public static final java.lang.String PROPERTY_MAX_THREAD_AGE
Configuration property for the max thread age.- See Also:
- Constant Field Values
-
PROPERTY_KEEP_ALIVE_TIME
public static final java.lang.String PROPERTY_KEEP_ALIVE_TIME
Configuration property for the keep alive time.- See Also:
- Constant Field Values
-
PROPERTY_BLOCK_POLICY
public static final java.lang.String PROPERTY_BLOCK_POLICY
Configuration property for the block policy.- See Also:
- Constant Field Values
-
PROPERTY_SHUTDOWN_GRACEFUL
public static final java.lang.String PROPERTY_SHUTDOWN_GRACEFUL
Configuration property for the shutdown graceful flag.- See Also:
- Constant Field Values
-
PROPERTY_SHUTDOWN_WAIT_TIME
public static final java.lang.String PROPERTY_SHUTDOWN_WAIT_TIME
Configuration property for the shutdown wait time.- See Also:
- Constant Field Values
-
PROPERTY_PRIORITY
public static final java.lang.String PROPERTY_PRIORITY
Configuration property for the priority.- See Also:
- Constant Field Values
-
PROPERTY_DAEMON
public static final java.lang.String PROPERTY_DAEMON
Configuration property for the daemon flag.- See Also:
- Constant Field Values
-
PROPERTY_NAME
public static final java.lang.String PROPERTY_NAME
Configuration property for the thread pool name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ModifiableThreadPoolConfig
public ModifiableThreadPoolConfig()
Create a new default configuration.
-
ModifiableThreadPoolConfig
public ModifiableThreadPoolConfig(ThreadPoolConfig copy)
Clone an existing configuration- Parameters:
copy
- The config to clone
-
-
Method Detail
-
getMinPoolSize
public int getMinPoolSize()
Description copied from interface:ThreadPoolConfig
Return the minimum pool size.- Specified by:
getMinPoolSize
in interfaceThreadPoolConfig
- Returns:
- The minimum pool size.
- See Also:
ThreadPoolConfig.getMinPoolSize()
-
setMinPoolSize
public void setMinPoolSize(int minPoolSize)
Set the min pool size.- Parameters:
minPoolSize
- New min pool size.
-
getMaxPoolSize
public int getMaxPoolSize()
Description copied from interface:ThreadPoolConfig
Return the maximum pool size- Specified by:
getMaxPoolSize
in interfaceThreadPoolConfig
- Returns:
- The maximum pool size.
- See Also:
ThreadPoolConfig.getMaxPoolSize()
-
setMaxPoolSize
public void setMaxPoolSize(int maxPoolSize)
Set the max pool size.- Parameters:
maxPoolSize
- New max pool size.
-
getQueueSize
public int getQueueSize()
Description copied from interface:ThreadPoolConfig
Return the queue size.- Specified by:
getQueueSize
in interfaceThreadPoolConfig
- Returns:
- The queue size.
- See Also:
ThreadPoolConfig.getQueueSize()
-
setQueueSize
public void setQueueSize(int queueSize)
Set the queue size.- Parameters:
queueSize
- New queue size.
-
getMaxThreadAge
public long getMaxThreadAge()
Description copied from interface:ThreadPoolConfig
Return the maximum age before a thread is retired.- Specified by:
getMaxThreadAge
in interfaceThreadPoolConfig
- Returns:
- The maximum age of a thread in milliseconds.
-
setMaxThreadAge
public void setMaxThreadAge(long maxThreadAge)
Deprecated.Since version 3.4.0 should no longer be called, as threads are no longer retired but instead the thread locals are cleaned up (SLING-6261)Set the max thread age.- Parameters:
maxThreadAge
- New max thread age in milliseconds.
-
getKeepAliveTime
public long getKeepAliveTime()
Description copied from interface:ThreadPoolConfig
Return the keep alive time.- Specified by:
getKeepAliveTime
in interfaceThreadPoolConfig
- Returns:
- The keep alive time.
- See Also:
ThreadPoolConfig.getKeepAliveTime()
-
setKeepAliveTime
public void setKeepAliveTime(long keepAliveTime)
Set the keep alive time.- Parameters:
keepAliveTime
- New keep alive time.
-
getBlockPolicy
public ThreadPoolConfig.ThreadPoolPolicy getBlockPolicy()
Description copied from interface:ThreadPoolConfig
Return the block policy.- Specified by:
getBlockPolicy
in interfaceThreadPoolConfig
- Returns:
- The block policy.
- See Also:
ThreadPoolConfig.getBlockPolicy()
-
setBlockPolicy
public void setBlockPolicy(ThreadPoolConfig.ThreadPoolPolicy blockPolicy)
Set the block policy.- Parameters:
blockPolicy
- The new block policy.- Throws:
java.lang.IllegalArgumentException
- If blockPolicy is null.
-
isShutdownGraceful
public boolean isShutdownGraceful()
Description copied from interface:ThreadPoolConfig
Should this pool shutdown graceful.- Specified by:
isShutdownGraceful
in interfaceThreadPoolConfig
- Returns:
true
if the pool should shutdown graceful.- See Also:
ThreadPoolConfig.isShutdownGraceful()
-
setShutdownGraceful
public void setShutdownGraceful(boolean shutdownGraceful)
Set if the pool should be shutdown graceful.- Parameters:
shutdownGraceful
- The shutdown graceful setting.
-
getShutdownWaitTimeMs
public int getShutdownWaitTimeMs()
Description copied from interface:ThreadPoolConfig
Return the shutdown wait time in ms. A value below 1 means no waiting at shutdown.- Specified by:
getShutdownWaitTimeMs
in interfaceThreadPoolConfig
- Returns:
- The shutdown wait time in ms.
- See Also:
ThreadPoolConfig.getShutdownWaitTimeMs()
-
setShutdownWaitTimeMs
public void setShutdownWaitTimeMs(int shutdownWaitTimeMs)
Set the shutdown wait time.- Parameters:
shutdownWaitTimeMs
- The new shutdown wait time.
-
getFactory
public java.util.concurrent.ThreadFactory getFactory()
Description copied from interface:ThreadPoolConfig
Return the thread pool factory. A value of null means the default jvm thread pool factory is used.- Specified by:
getFactory
in interfaceThreadPoolConfig
- Returns:
- The thread pool factory or
null
- See Also:
ThreadPoolConfig.getFactory()
-
setFactory
public void setFactory(java.util.concurrent.ThreadFactory factory)
Set the thread factory.- Parameters:
factory
- The thread factory to be used ornull
to use the default thread factory.
-
getPriority
public ThreadPoolConfig.ThreadPriority getPriority()
Description copied from interface:ThreadPoolConfig
Return the priority for the threads.- Specified by:
getPriority
in interfaceThreadPoolConfig
- Returns:
- The priority for the threads.
- See Also:
ThreadPoolConfig.getPriority()
-
setPriority
public void setPriority(ThreadPoolConfig.ThreadPriority priority)
Set the thread priority.- Parameters:
priority
- The thread priority.- Throws:
java.lang.IllegalArgumentException
- If priority is null.
-
isDaemon
public boolean isDaemon()
Description copied from interface:ThreadPoolConfig
Return if daemon threads should be created.- Specified by:
isDaemon
in interfaceThreadPoolConfig
- Returns:
true
if daemon threads should be created.- See Also:
ThreadPoolConfig.isDaemon()
-
setDaemon
public void setDaemon(boolean isDaemon)
Set the daemon handling.- Parameters:
isDaemon
- The daemon setting.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-