Schedule at 24hrs interval

前端 未结 4 1282
萌比男神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:35

    Well, if the program can be idle try something like this

    try
    {
    for (;;) {
        //code
        Thread.sleep(1000 * 60 * 60 * 24);
        //code
        }
    }
    catch(Exception e)
    {
         System.out.println(e);
    }
    

提交回复
热议问题