经研究,我推荐这种写法:
复制代码 代码如下:
<SPAN xmlns="http://www.w3.org/1999/xhtml">/*自定义线程*/
class MyThread implements Runnable{
public void run() {
// TODO Auto-generated method stub
// 定义自己的变量
while(!Thread.currentThread().isInterrupted()){
try {
doSomeThingNeed();//需要更新的操作
//休眠控制最大帧率为每秒3绘制30次
Thread.sleep(30);
} catch (Exception e) {
// TODO: handle exception
Log.v(tag2, "DrawSurfaceView:绘制失败...");
Thread.currentThread().interrupt();
}
}
}</SPAN>