public class StrategicExecutors
extends java.lang.Object
BalancingThreadPoolExecutor
instances.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BALANCE_AFTER |
static float |
DEFAULT_SMOOTHING_WEIGHT |
Constructor and Description |
---|
StrategicExecutors() |
Modifier and Type | Method and Description |
---|---|
static BalancingThreadPoolExecutor |
newBalancingThreadPoolExecutor(int maxThreads,
float targetUtilization)
Return a capped
BalancingThreadPoolExecutor with the given
maximum number of threads and target utilization. |
static BalancingThreadPoolExecutor |
newBalancingThreadPoolExecutor(int maxThreads,
float targetUtilization,
float smoothingWeight,
int balanceAfter)
Return a capped
BalancingThreadPoolExecutor with the given
maximum number of threads, target utilization, smoothing weight, and
balance after values. |
static BalancingThreadPoolExecutor |
newBalancingThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor tpe,
float targetUtilization,
float smoothingWeight,
int balanceAfter)
Return a
BalancingThreadPoolExecutor with the given
ThreadPoolExecutor , target utilization, smoothing weight, and
balance after values. |
public static final float DEFAULT_SMOOTHING_WEIGHT
public static final int DEFAULT_BALANCE_AFTER
public static BalancingThreadPoolExecutor newBalancingThreadPoolExecutor(int maxThreads, float targetUtilization)
BalancingThreadPoolExecutor
with the given
maximum number of threads and target utilization. The default smoothing
weight and balance after constants are used.maxThreads
- maximum number of threads to usetargetUtilization
- a float between 0.0 and 1.0 representing the
percentage of the total CPU time to be used by
this poolpublic static BalancingThreadPoolExecutor newBalancingThreadPoolExecutor(int maxThreads, float targetUtilization, float smoothingWeight, int balanceAfter)
BalancingThreadPoolExecutor
with the given
maximum number of threads, target utilization, smoothing weight, and
balance after values.maxThreads
- maximum number of threads to usetargetUtilization
- a float between 0.0 and 1.0 representing the
percentage of the total CPU time to be used by
this poolsmoothingWeight
- smooth out the averages of the CPU and wait time
over time such that tasks aren't too heavily
skewed with old or spiking databalanceAfter
- balance the thread pool after this many tasks
have runpublic static BalancingThreadPoolExecutor newBalancingThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor tpe, float targetUtilization, float smoothingWeight, int balanceAfter)
BalancingThreadPoolExecutor
with the given
ThreadPoolExecutor
, target utilization, smoothing weight, and
balance after values.tpe
- the underlying executor to use for this instancetargetUtilization
- a float between 0.0 and 1.0 representing the
percentage of the total CPU time to be used by
this poolsmoothingWeight
- smooth out the averages of the CPU and wait time
over time such that tasks aren't too heavily
skewed with old or spiking databalanceAfter
- balance the thread pool after this many tasks
have run