210 |
|
final CountDownLatch done = new CountDownLatch(cycles); |
211 |
|
Runnable task = new CheckedRunnable() { |
212 |
|
public void realRun() { done.countDown(); }}; |
213 |
< |
ScheduledFuture h = |
213 |
> |
ScheduledFuture periodicTask = |
214 |
|
p.scheduleAtFixedRate(task, 0, delay, MILLISECONDS); |
215 |
|
await(done); |
216 |
< |
h.cancel(true); |
217 |
< |
double normalizedTime = |
216 |
> |
periodicTask.cancel(true); |
217 |
> |
double elapsedDelays = |
218 |
|
(double) millisElapsedSince(startTime) / delay; |
219 |
< |
if (normalizedTime >= cycles - 1 && |
220 |
< |
normalizedTime <= cycles) |
219 |
> |
if (elapsedDelays >= cycles - 1 && |
220 |
> |
elapsedDelays <= cycles) |
221 |
|
return; |
222 |
|
} |
223 |
< |
throw new AssertionError("unexpected execution rate"); |
223 |
> |
fail("unexpected execution rate"); |
224 |
|
} |
225 |
|
} |
226 |
|
|
236 |
|
final CountDownLatch done = new CountDownLatch(cycles); |
237 |
|
Runnable task = new CheckedRunnable() { |
238 |
|
public void realRun() { done.countDown(); }}; |
239 |
< |
ScheduledFuture h = |
239 |
> |
ScheduledFuture periodicTask = |
240 |
|
p.scheduleWithFixedDelay(task, 0, delay, MILLISECONDS); |
241 |
|
await(done); |
242 |
< |
h.cancel(true); |
243 |
< |
double normalizedTime = |
242 |
> |
periodicTask.cancel(true); |
243 |
> |
double elapsedDelays = |
244 |
|
(double) millisElapsedSince(startTime) / delay; |
245 |
< |
if (normalizedTime >= cycles - 1 && |
246 |
< |
normalizedTime <= cycles) |
245 |
> |
if (elapsedDelays >= cycles - 1 && |
246 |
> |
elapsedDelays <= cycles) |
247 |
|
return; |
248 |
|
} |
249 |
< |
throw new AssertionError("unexpected execution rate"); |
249 |
> |
fail("unexpected execution rate"); |
250 |
|
} |
251 |
|
} |
252 |
|
|