Is this a proper Android Game Loop?
<p>I grabbed this from the book I'm learning from.</p>

<pre><code>public void run()
{
    // this is the method that gets called when the thread is started.

    // first we get the current time before the loop starts
    long startTime = System.currentTimeMillis();

    // start the animation loop
    while (running)
    {
        // we have to make sure that the surface has been created
        // if not we wait until it gets created
        if (!holder.getSurface ().isValid())
            continue;

        // get the time elapsed since the loop was started
        // this is important to achieve frame rate-independent movement,
        // otherwise on faster processors the animation will go too fast
        float timeElapsed = (System.currentTimeMillis () - startTime);

        // is it time to display the next frame?
        if (timeElapsed &gt; FRAME_RATE)
        {
            // compute the next step in the animation
            update();

            // display the new frame
            display();

            // reset the start time
            startTime = System.currentTimeMillis();
        }
    }

    // run is over: thread dies
}
</code></pre>

<p>Does it account for lag correctly and is it optimal?</p>

<p>What I mean is, if the video cannot update 60 times per second will the update() be called 60x per second?</p>

<p>Thanks</p>
