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 voidrunAgainAfter(Runnable runnable, String key, ChronoUnit unit, long expires) Runs theRunnablewith the same key only once in a specified time frame.
-
Constructor Details
-
OnceInAWhileRunner
public OnceInAWhileRunner()
-
-
Method Details
-
runAgainAfter
Runs theRunnablewith 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- theChronoUnitwhich 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.
-