Fix thread F3 avg time >0 when runtime ratio is 1
This commit is contained in:
+3
-2
@@ -84,12 +84,13 @@ public class RateLimitedThreadPoolExecutor extends ThreadPoolExecutor
|
||||
{
|
||||
super.beforeExecute(thread, runnable);
|
||||
|
||||
long deltaMs = TimeUnit.NANOSECONDS.toMillis(this.lastRunDurationNanoTimeRef.get());
|
||||
this.runTimeInMsRollingAverage.addValue(deltaMs);
|
||||
|
||||
if (this.runTimeRatio < 1.0 && this.lastRunDurationNanoTimeRef.get() != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
long deltaMs = TimeUnit.NANOSECONDS.toMillis(this.lastRunDurationNanoTimeRef.get());
|
||||
this.runTimeInMsRollingAverage.addValue(deltaMs);
|
||||
Thread.sleep((long) (deltaMs / this.runTimeRatio - deltaMs));
|
||||
}
|
||||
catch (InterruptedException ignored) { }
|
||||
|
||||
Reference in New Issue
Block a user