/** * Return a {@link BalancingThreadPoolExecutor} with the given * {@link ThreadPoolExecutor}, target utilization, smoothing weight, and * balance after values. * * @param tpe the underlying executor to use for this instance * @param targetUtilization a float between 0.0 and 1.0 representing the * percentage of the total CPU time to be used by * this pool * @param smoothingWeight smooth out the averages of the CPU and wait time * over time such that tasks aren't too heavily * skewed with old or spiking data * @param balanceAfter balance the thread pool after this many tasks * have run */ public static BalancingThreadPoolExecutor newBalancingThreadPoolExecutor(ThreadPoolExecutor tpe, float targetUtilization, float smoothingWeight, int balanceAfter) { ThreadProfiler tp = new MXBeanThreadProfiler(); return new BalancingThreadPoolExecutor(tpe, tp, targetUtilization, smoothingWeight, balanceAfter); } }
if(!isTerminated()) { Set<Map.Entry<Thread, Tracking>> threads = liveThreads.entrySet(); long liveAvgTimeTotal = 0;