public static void main (String[] args)
    {
        // set up a throttle for 5 ops per 10 seconds
        Throttle throttle = new Throttle(5, 10000);

        // try doing one operation per second and we should hit the throttle on the sixth operation
        // and then kick in again on the eleventh, only to stop again on the fifteenth
        for (int i = 0; i < 20; i++) {
            System.out.println((i+1) + ". Throttle: " + throttle.throttleOp());
            // pause for a sec
            try { Thread.sleep(1000L); }
            catch (InterruptedException ie) {}
        }
    }
public static void main ( String [ ] args ) { Throttle throttle = new Throttle ( 5 , 10000 ) ; for ( int i = 0 ; i < 20 ; i ++ ) { System . out . println ( ( i + 1 ) + ". Throttle: " + throttle . throttleOp ( ) ) ; try { Thread . sleep ( 1000L ) ; } catch ( InterruptedException ie ) { } } }
Used for testing.