Class ThreadHelper

java.lang.Object
com.helger.base.concurrent.ThreadHelper

@Immutable @ThreadSafe public final class ThreadHelper extends Object
Some thread utility methods.
Author:
Philip Helger
  • Method Details

    • sleepMinutes

      public static @NonNull ESuccess sleepMinutes(@Nonnegative long nMinutes)
      Sleep the current thread for a certain amount of time
      Parameters:
      nMinutes - The minutes to sleep. Must be ≥ 0.
      Returns:
      ESuccess.SUCCESS if sleeping was not interrupted, ESuccess.FAILURE if sleeping was interrupted
    • sleepSeconds

      public static @NonNull ESuccess sleepSeconds(@Nonnegative long nSeconds)
      Sleep the current thread for a certain amount of time
      Parameters:
      nSeconds - The seconds to sleep. Must be ≥ 0.
      Returns:
      ESuccess.SUCCESS if sleeping was not interrupted, ESuccess.FAILURE if sleeping was interrupted
    • sleep

      public static @NonNull ESuccess sleep(@NonNull Duration aDuration)
      Sleep the current thread for a certain amount of time
      Parameters:
      aDuration - The time value to use. May not be null.
      Returns:
      ESuccess.SUCCESS if sleeping was not interrupted, ESuccess.FAILURE if sleeping was interrupted
    • sleep

      public static @NonNull ESuccess sleep(@Nonnegative long nDuration, @NonNull TimeUnit aTimeUnit)
      Sleep the current thread for a certain amount of time
      Parameters:
      nDuration - The duration to sleep. Must be ≥ 0.
      aTimeUnit - The time unit to use. May not be null.
      Returns:
      ESuccess.SUCCESS if sleeping was not interrupted, ESuccess.FAILURE if sleeping was interrupted
    • sleep

      public static @NonNull ESuccess sleep(@Nonnegative long nMilliseconds)
      Sleep the current thread for a certain amount of time
      Parameters:
      nMilliseconds - The milliseconds to sleep. Must be ≥ 0.
      Returns:
      ESuccess.SUCCESS if sleeping was not interrupted, ESuccess.FAILURE if sleeping was interrupted