Example usage for org.springframework.scheduling TaskScheduler scheduleAtFixedRate

List of usage examples for org.springframework.scheduling TaskScheduler scheduleAtFixedRate

Introduction

In this page you can find the example usage for org.springframework.scheduling TaskScheduler scheduleAtFixedRate.

Prototype

ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long period);

Source Link

Document

Schedule the given Runnable , starting as soon as possible and invoking it with the given period.

Usage

From source file:com.netflix.genie.web.health.GenieCpuHealthIndicator.java

GenieCpuHealthIndicator(final double maxCpuLoadPercent, final int maxCpuLoadConsecutiveOccurrences,
        final OperatingSystemMXBean operatingSystemMXBean, final BasicDistributionSummary summaryCpuMetric,
        final TaskScheduler taskScheduler) {
    this.maxCpuLoadPercent = maxCpuLoadPercent;
    this.maxCpuLoadConsecutiveOccurrences = maxCpuLoadConsecutiveOccurrences;
    this.operatingSystemMXBean = operatingSystemMXBean;
    this.summaryCpuMetric = summaryCpuMetric;
    this.summaryCpuMetric.record((long) (operatingSystemMXBean.getSystemCpuLoad() * 100));
    taskScheduler.scheduleAtFixedRate(
            () -> this.summaryCpuMetric.record((long) (operatingSystemMXBean.getSystemCpuLoad() * 100)), 5000);
}