Run a program or method at specific time in Java

后端 未结 4 1728
忘掉有多难
忘掉有多难 2020-12-21 20:46

I just want that my program or method should run at specific date and time. i have heard about Timer and TimerTask in java API. But don\'t know exactly how to use it.

4条回答
  •  遥遥无期
    2020-12-21 21:20

    If this is for your own benefit and not for a project I would suggest you look into http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html which is a replacement for java.util.Timer. If however you want a robust scheduler, I concur with the previous posters with regards to Quartz.

提交回复
热议问题