Reputation: 24288
There is a directory in which files arrive at unpredictable times, but suppose that probability distribution is normal.
Average intervals for polling must be 1 minute.
Does there exist some strategy - e.g. change near 20% (+ or -) interval for polling or better polling in equal intervals? If yes - if possible please point to an algorithm in java
Upvotes: 2
Views: 1435
Reputation: 4096
You can also implement this using awaitility
. Please check here
Upvotes: 0
Reputation: 17350
Instead of polling yourself you might want to look at FileAlterationMonitor or JNotify or NIO (Java 7 only).
Upvotes: 4
Reputation: 78975
It might yet be too early for you, but Java 7 has new class WatchService for monitoring a directory for changes.
Upvotes: 2