JavaTimer Can be used when you want to specify a time at regular intervals and execute processing
JavaTimer
import java.util.Timer;
import java.util.TimerTask;
public class TimeAction {
public static void main(String[] args) {
Timer timer = new Timer();
TimerTask tt = new TimerTask() {
int count = 0;
public void run() {
//Processing that you want to execute on a regular basis
count++;
System.out.println(count + "It's the second task.");
}
};
//After 2 seconds, run every 5 seconds
timer.scheduleAtFixedRate(tt,2000,5000);
}
//timer.cancel();If you don't write, the process will work all the time, so be careful!
}