Example usage for org.springframework.scheduling.concurrent ScheduledExecutorTask isFixedRate

List of usage examples for org.springframework.scheduling.concurrent ScheduledExecutorTask isFixedRate

Introduction

In this page you can find the example usage for org.springframework.scheduling.concurrent ScheduledExecutorTask isFixedRate.

Prototype

public boolean isFixedRate() 

Source Link

Document

Return whether to schedule as fixed-rate execution.

Usage

From source file:org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean.java

/**
 * Register the specified {@link ScheduledExecutorTask ScheduledExecutorTasks}
 * on the given {@link ScheduledExecutorService}.
 * @param tasks the specified ScheduledExecutorTasks (never empty)
 * @param executor the ScheduledExecutorService to register the tasks on.
 *///from w  w w .  j a  va  2s.  co m
protected void registerTasks(ScheduledExecutorTask[] tasks, ScheduledExecutorService executor) {
    for (int i = 0; i < tasks.length; i++) {
        ScheduledExecutorTask task = tasks[i];
        Runnable runnable = getRunnableToSchedule(task);
        if (task.isOneTimeTask()) {
            executor.schedule(runnable, task.getDelay(), task.getTimeUnit());
        } else {
            if (task.isFixedRate()) {
                executor.scheduleAtFixedRate(runnable, task.getDelay(), task.getPeriod(), task.getTimeUnit());
            } else {
                executor.scheduleWithFixedDelay(runnable, task.getDelay(), task.getPeriod(),
                        task.getTimeUnit());
            }
        }
    }
}