Class OnceInAWhileRunner

java.lang.Object
de.cxp.ocs.util.OnceInAWhileRunner

public class OnceInAWhileRunner extends Object
Offers the possibility to run a Runnable function, once in a defined time frame.
  • Constructor Details

    • OnceInAWhileRunner

      public OnceInAWhileRunner()
  • Method Details

    • runAgainAfter

      public static void runAgainAfter(Runnable runnable, String key, ChronoUnit unit, long expires)
      Runs the Runnable 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 - the ChronoUnit which describes the time frame. Please refer to Instant.plus(java.time.temporal.TemporalAmount) for a list of supported units.
      expires - the frame span for the specified unit.