long start = System.currentTimeMillis();
long lowTolerance = (total * period) * 4 / 5;
long highTolerance = (total * period) * 5 / 4;
for (int i = 0; i < total * period; i++)
{
limiter.submit(incr);
}
Assert.assertTrue(latch.await(highTolerance, TimeUnit.MILLISECONDS),
"Should have finished within " + highTolerance + "ms");
long t = System.currentTimeMillis() - start;
Assert.assertTrue(t > lowTolerance, "Should have finished after " + lowTolerance + "ms (took " + t + ")");