This is a timer, which is executed at regular intervals and used to send emails at regular intervals.

public static void main(String[] args) {
//1. Create timer class
Timer timer = new Timer();
//2. Create task class
TimerTask task = new TimerTask() {
@Override
public void run() {
SendMail.maina();
System.out.println("Time: " + new Timestamp(System.currentTimeMillis()));
}
};
//3. Execute the task, start the task after 3 seconds
timer.schedule(task, 1000, 1000);
System.out.println("Main thread continues to run");
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325302809&siteId=291194637