私は私が学んでいる本からこれをつかみました。
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 > 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
}
ラグを正しく考慮しており、最適ですか?
つまり、ビデオが1秒間に60回更新できない場合、update()は1秒間に60回呼び出されますか?
ありがとう