AKA doing something at set intervals.
For example, let's say I want to scan a certain directory every 60 seconds.
In Java, I would use a ScheduledExecutorService
like so:
Executor pool = Executors.newScheduledThreadPool(10)
pool.scheduleAtFixedRate(scanner, 0, 60, TimeUnit.SECONDS)
and that works fine.
The thing is, I'm thinking I'd like to try using Scala actors in my program, but I'm a little confused as to how to combine actors and Java Executors, or whether they should be.
I guess maybe I could have a simple runner which would merely send a message to an actor every N seconds -- does that make sense?
I guess maybe I could have a simple runner which would merely send a message to an actor every N seconds -- does that make sense?
Yes, and consider using Akka for the Actors by the way. It has a simpler API, better performance and has a lot of yummy stuff in it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With