Package de.cxp.ocs.util
Class OnceInAWhileRunner
java.lang.Object
de.cxp.ocs.util.OnceInAWhileRunner
Offers the possibility to run a
Runnable
function, once in a
defined time frame.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
runAgainAfter
(Runnable runnable, String key, ChronoUnit unit, long expires) Runs theRunnable
with the same key only once in a specified time frame.
-
Constructor Details
-
OnceInAWhileRunner
public OnceInAWhileRunner()
-
-
Method Details
-
runAgainAfter
Runs theRunnable
with the same key only once in a specified time frame.- Parameters:
runnable
- the runnable to run.key
- the key which should be unique for the same runnable.unit
- theChronoUnit
which describes the time frame. Please refer toInstant.plus(java.time.temporal.TemporalAmount)
for a list of supported units.expires
- the frame span for the specified unit.
-