简体   繁体   中英

scheduleAtFixRate runs every 10 minutes instead of hourly

I have created a job to run every hour as follows

public class BackgroundJobManager implements ServletContextListener {

    private ScheduledExecutorService scheduler;

    public void contextInitialized(ServletContextEvent sce) { 
        .
        .
        scheduler = Executors.newSingleThreadScheduledExecutor();
        scheduler.scheduleAtFixedRate(new HourlyJob(), 0, 1, TimeUnit.HOURS);
        .
        .
    }
}

But HourlyJob() is executing every 10 minutes instead of hourly. Not sure what wrong I am doing here.

Does anyone know why the TimeUnit.HOURS is not considered as expected?

It may be an annotation for scheduled task's method @Schedule

@Schedule(hour = "*")
public void doHourlyJob() {
    ....
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM