BAEL-4322 add sample codes for dynamic delay setting (#10531)
Co-authored-by: Yavuz Tas <ytas@vwd.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user