If you like a mailbox with a maximum capacity of 1 and discarding overflow messages, I recommend using java.util.Timer instead of Akka.
This is what I wrote in my Scala program:
MyTask.scala:
object MyTask extends TimerTask { var isRunning = false; def run() { if (!isRunning) { isRunning = true [...] isRunning = false } } }
Task execution after 0 ms, repeating every second:
new Timer().schedule(MyTask, 0, 1000)
source share