Files
spring-boot-rest/spring-all/src/main/java/com/baeldung/scheduling/ScheduledFixedRateExample.java
2019-08-03 15:24:39 +03:00

19 lines
575 B
Java

package com.baeldung.scheduling;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
@EnableAsync
public class ScheduledFixedRateExample {
@Async
@Scheduled(fixedRate = 1000)
public void scheduleFixedRateTaskAsync() throws InterruptedException {
System.out.println("Fixed rate task async - " + System.currentTimeMillis() / 1000);
Thread.sleep(2000);
}
}