### Question:
TimeWindowRequestThrottle implements RequestThrottle { public TimeWindowRequestThrottle(long timeWindow, TimeUnit unit, int maximumRequests) { Validate.isTrue(timeWindow > 0, "timeWindow must be greater zero"); Validate.notNull(unit, "unit must not be null"); Validate.isTrue(maximumRequests > 0, "maximumRequests must be greater zero"); this.timeWindow = unit.toMillis(timeWindow); this.maximumRequests = maximumRequests; this.requestTimestamps = new LinkedList<>(); this.totalThrottledTime = 0; } TimeWindowRequestThrottle(long timeWindow, TimeUnit unit, int maximumRequests); @Override synchronized void hold(); synchronized int getNumRequestsInWindow(); long getTotalThrottledTime(); @Override String toString();  }### Answer:
@Test public void testTimeWindowRequestThrottle() throws InterruptedException { TimeWindowRequestThrottle throttle = new TimeWindowRequestThrottle(1, TimeUnit.SECONDS, 3); StopWatch stopWatch = new StopWatch(); for (int millisToSleep : Arrays.asList(0, 0, 0, 0, 0, 100, 0, 100, 100, 100)) { throttle.hold(); Thread.sleep(millisToSleep); assertTrue(throttle.getNumRequestsInWindow() <= 3); } assertTrue(2600 < throttle.getTotalThrottledTime()); assertTrue(2800 > throttle.getTotalThrottledTime()); assertTrue(2900 < stopWatch.getElapsedTime()); assertTrue(3200 > stopWatch.getElapsedTime()); }