/** * Waits until data is _availableBytes. */ private void waitForBandwidth() { while(true) { long now = System.currentTimeMillis(); updateWindow(now); if(availableBytes != 0) { break; } try { if(log.isInfoEnabled()) { log.info(String.format("Throttling bandwidth for %d milliseconds", nextTickTime - now)); } Thread.sleep(nextTickTime - now); } catch(InterruptedException e) { log.error(e.getMessage(), e); } } }