第一頁
返回
繼續
最後一頁
摘要
圖形
Service的寫法(二)
為了持續不斷背景執行,通常會開另外的 Thread,並用while (true) 配合delay 運行
new Thread(){
public void run(){
while(true)
{
//程式寫這裡
try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
}
}}