Public boolean checkStatus(){
if(case){
return true;
}
return false;
}
final ActorSystem system = ActorSystem.apply();
Cancellable result = system.scheduler.schedule(Duration.create(delay,TimeUnit.MILLISECONDS),Duration.create(interval, TimeUnit.MILLISECONDS)(checkStatus());
How i can stop scheduler when checkStatus case is true.
Instead of cancelling scheduled task you can use
scheduleOnce
method instead and then schedule it again if check is false or not if it's true. You will get the semantics you want that way.Something along those lines: