Referring specifically to the JDK documentation: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Timer.html
package threadStudy; import java.util.Timer; import java.util.TimerTask; public class TimerTest extends TimerTask { @Override public void run() { System.out.println ( "though June but still a little cold ..." ); } public static void main(String[] args) { TimerTest timerTest = new TimerTest(); Timer the Timer = new new the Timer (); // begin after repeatedly performed every 2s lS timer.scheduleAtFixedRate (TimerTest, 1000, 2000 ); } }
Timing scheduling framework: the Quartz
https://www.w3cschool.cn/quartz_doc/quartz_doc-2put2clm.html