How to schedule a periodic task in Java?

前端 未结 11 1787
星月不相逢
星月不相逢 2020-11-22 08:51

I need to schedule a task to run in at fixed interval of time. How can I do this with support of long intervals (for example on each 8 hours)?

I\'m currently using <

11条回答
  •  庸人自扰
    2020-11-22 09:10

    my servlet contains this as a code how to keep this in scheduler if a user presses accept

    if(bt.equals("accept")) {
        ScheduledExecutorService scheduler=Executors.newScheduledThreadPool(1);
        String lat=request.getParameter("latlocation");
        String lng=request.getParameter("lnglocation");
        requestingclass.updatelocation(lat,lng);
    }
    

提交回复
热议问题