public class Throttle
extends java.lang.Object
Instances are intended for use by one thread, and so they are not thread-safe.
Constructor and Description |
---|
Throttle(int windowSize) |
public Throttle(int windowSize)
windowSize
- amount of samples to keep in the rolling averagepublic void throttle(double desiredSpeed, long sleepPrecisionMillis) throws java.lang.InterruptedException
desiredSpeed
- 1.0 = perform work at full speed,
0.5 = perform work at half speed, 0.0 = fully suspend worksleepPrecisionMillis
- sleep precision, in milliseconds. Typical
value is 10 to 100 milliseconds.java.lang.InterruptedException
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- args[0] - desired speed, 0.0 to 1.0java.lang.Exception
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.