new Thread(){
public void run(){
try {
sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while(hasData < 100){
progressStatus = progressStatus + (int)(Math.random() * 10);
handler.sendEmptyMessage(0x123);
// if(hasData >= 100){
// Toast.makeText(MainActivity.this,"耗时任务已完成",1).show();
// }
}
}
}.start();
}
备注progressStatus和handler已经在上面声明了。