BAEL-4322 add sample codes for dynamic delay setting (#10531)

Co-authored-by: Yavuz Tas <ytas@vwd.com>
This commit is contained in:
Yavuz Tas
2021-03-16 03:19:20 +01:00
committed by GitHub
parent 735f0d1bda
commit 0130e412af
3 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package com.baeldung.scheduling.dynamic;
import org.springframework.stereotype.Service;
@Service
public class TickService {
private long delay = 0;
public long getDelay() {
this.delay += 1000;
System.out.println("delaying " + this.delay + " milliseconds...");
return this.delay;
}
public void tick() {
final long now = System.currentTimeMillis() / 1000;
System.out
.println("schedule tasks with dynamic delay - " + now);
}
}