Schedule at 24hrs interval

前端 未结 4 1319
萌比男神i
萌比男神i 2021-01-20 02:00

I want to know the best method to schedule a code. I have a code that generates reports and sends mail to a set of people at interval of 24hrs. Its a console based java appl

4条回答
  •  温柔的废话
    2021-01-20 02:28

    I am using two ways:

    First for non managed code like client code: Chron4J

    Second is implmented in the JavaEE framewoks. You can use it via annotating methods when you use an container like Glassfish/JBoss. Would be something like this:

    @Schedule(second="*/1", minute="*",hour="*", persistent=false)
    public void doWork(){
        System.out.println("timer: " + helloService.sayHello());
    }
    

提交回复
热议问题