我的Java类中有这段代码
package me.mario.timer;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
public class AutoSyncDatabase {
Runnable helloRunnable = new Runnable() {
public void run() {
System.out.println("Hello world");
}
};
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
executor.scheduleAtFixedRate(helloRunnable, 0, 3, TimeUnit.SECONDS);
}
但是我在此行收到错误Syntax error on tokens, delete these tokens
:
executor.scheduleAtFixedRate(helloRunnable, 0, 3, TimeUnit.SECONDS);
我尝试了很多方法来修复它,但是没有任何运气。
任何帮助将不胜感激!
谢谢。