Data Structures, Algorithms, & Applications in Java
Chapter 4, Exercise 1

In each iteration of the while loop, the amount added to elapsedTime may deviate from the actual run time of doSomething by up to 100 ms. This error is additive over the iterations and so does not decline as a fraction of total time.

For example, suppose that doSomething takes almost 100 ms. to execute. In the worst case, the clock reading will change just before each execution of the assignment startTime = System.currentTimeMillis() and the amount added to elapsedTime is zero on each iteration of the while loop; the while loop does not terminate.