如何給服務器更新數據?我使用下面的代碼,但是10分鐘後還是沒有執行。
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
executor.scheduleWithFixedDelay(new Runnable(){
public void run() {
//update data to server
}
}, 0, 600, TimeUnit.SECONDS);
我是在activity中測試下面這段代碼的,都有執行,一直在輸出結構
protected void onCreate(Bundle savedInstanceState) {
test();
}
void test(){
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
executor.scheduleWithFixedDelay(new Runnable(){
public void run() {
System.out.println("test() ------------> run()");
//update data to server
}
}, 0, 1, TimeUnit.SECONDS);
}