我从我正在学习的书中抓住了这个。
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
}
它是否正确解释了延迟并且是最佳的?
我的意思是,如果视频不能每秒更新 60 次,那么 update() 会被称为每秒 60 次吗?
谢谢