Run java function every hour

前端 未结 4 780
孤街浪徒
孤街浪徒 2020-12-19 09:02

I want to run a function every hour, to email users a hourly screenshot of their progress. I code set up to do so in a function called sendScreenshot()

How can I run

4条回答
  •  悲&欢浪女
    2020-12-19 09:45

    According to this article by Oracle, it's also possible to use the @Schedule annotation:

    @Schedule(hour = "*")
    public void doSomething() {
        System.out.println("hello world");
    }
    

    For example, seconds and minutes can have values 0-59, hours 0-23, months 1-12.

    Further options are also described there.

提交回复
热议问题