📅  最后修改于: 2022-03-11 14:52:38.040000             🧑  作者: Mango
/* Perform this runnable code every 5 seconds in this example*/
Runnable runnable = new Runnable() {
public void run() {
// task to run goes here
System.out.println("Hello !!");
}
};
ScheduledExecutorService service = Executors
.newSingleThreadScheduledExecutor();
service.scheduleAtFixedRate(runnable, 0, 5, TimeUnit.SECONDS);