Advertisement
STANAANDREY

scheduler java

Aug 23rd, 2021
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.text.DateFormat;
  4. import java.text.SimpleDateFormat;
  5. import java.util.Date;
  6. import java.util.Timer;
  7. import java.util.TimerTask;
  8.  
  9. class Scheduler extends TimerTask {
  10.     public void run() {
  11.         System.out.println("RUN!!!");
  12.     }
  13. }
  14.  
  15. public class Main {
  16.     public static void main(String[] args) throws Exception {
  17.         DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  18.         Date date = dateFormatter.parse("2021-08-19 12:26:00");
  19.         var timer = new Timer();
  20.         final long period = 10000;
  21.         timer.schedule(new Scheduler(), date, period);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement