一、开启新线程
newThread(newRunnable(){
publicvoidrun(){
Thread.sleep(XXXX);
handler.sendMessage();//告诉主线程执行任务
}
}).start
二、利用定时器
TimerTasktask=newTimerTask(){
publicvoidrun(){
//executethetask
}
};
Timer timer = new Timer();
timer.schedule(task, delay);
三、handler + postDelayed
newHandler().postDelayed(newRunnable(){
publicvoidrun(){
//executethetask
}
},delay);
网友评论