Interface Runnable

All Superinterfaces:
Runnable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface
public interface Runnable
extends Runnable
This is a functional interface that accepts nothing and returns nothing.
  • Method Details

    • run

      void run()
      Specified by:
      run in interface Runnable
      See Also:
      Runnable.run()
    • andThen

      default Runnable andThen​(Runnable after)
      Returns a composed Runnable that performs, in sequence, this operation followed by the after operation. If performing either operation throws an exception, it is relayed to the caller of the composed operation. If performing this operation throws an exception, the after operation will not be performed.
      Parameters:
      after - the operation to perform after this operation
      Returns:
      a composed Runnable that performs in sequence this operation followed by the after operation
      Throws:
      NullPointerException - if after is null
    • andThen

      default <T,​ F extends Supplier<T>> F andThen​(F after)
      Like andThen(Runnable), but creates a Supplier.
      Type Parameters:
      T - The type to return.
      F - The type of supplier to chain.
      Parameters:
      after - the operation to perform after this operation
      Returns:
      a composed Runnable that performs in sequence this operation followed by the after operation
    • andThen

      default <T,​ F extends Consumer<T>> F andThen​(F after)
      Like andThen(Runnable), but creates a Consumer.
      Type Parameters:
      T - The type to accept.
      F - The type of consumer to chain.
      Parameters:
      after - the operation to perform after this operation
      Returns:
      a composed Runnable that performs in sequence this operation followed by the after operation
    • andThen

      default <T,​ U,​ F extends BiConsumer<T,​ U>> F andThen​(F after)
      Like andThen(Runnable), but creates a BiConsumer.
      Type Parameters:
      T - The first type to accept.
      U - The second type to accept.
      F - The type of BiConsumer to chain.
      Parameters:
      after - the operation to perform after this operation
      Returns:
      a composed Runnable that performs in sequence this operation followed by the after operation
    • andThen

      default <T,​ U,​ V,​ F extends TriConsumer<T,​ U,​ V>> F andThen​(F after)
      Like andThen(Runnable), but creates a TriConsumer.
      Type Parameters:
      T - The first type to accept.
      U - The second type to accept.
      V - The third type to accept.
      F - The type of TriConsumer to chain.
      Parameters:
      after - the operation to perform after this operation
      Returns:
      a composed Runnable that performs in sequence this operation followed by the after operation
    • andThen

      default <T,​ R,​ F extends Function<T,​ R>> F andThen​(F after)
      Like andThen(Runnable), but creates a Function.
      Type Parameters:
      T - The type to accept.
      F - The type of function to chain.
      R - The type returned by the after function.
      Parameters:
      after - the operation to perform after this operation
      Returns:
      a composed Runnable that performs in sequence this operation followed by the after operation
    • andThen

      default <T,​ U,​ R,​ F extends BiFunction<T,​ U,​ R>> F andThen​(F after)
      Like andThen(Runnable), but creates a BiFunction.
      Type Parameters:
      F - The type of function to chain.
      T - The first type to accept.
      U - The second type to accept.
      R - The return type of the after function.
      Parameters:
      after - the operation to perform after this operation
      Returns:
      a composed Runnable that performs in sequence this operation followed by the after operation
    • andThen

      default <T,​ U,​ V,​ R,​ F extends TriFunction<T,​ U,​ V,​ R>> F andThen​(F after)
      Like andThen(Runnable), but creates a TriFunction.
      Type Parameters:
      F - The type of TriFunction to chain.
      T - The first type to apply.
      U - The second type to apply.
      V - The third type to apply.
      R - The return type of the chained function.
      Parameters:
      after - the operation to perform after this operation
      Returns:
      a composed Runnable that performs in sequence this operation followed by the after operation
    • forever

      default Runnable forever()
      Returns:
      A version of this Runnable that calls the run() method repeatedly forever. This will never terminate unexceptionally.
    • loopFor

      default Runnable loopFor​(int times)
      Parameters:
      times - The number of times to loop.
      Returns:
      A version of this Runnable that calls the run() method a given number of times
    • whileTrue

      default Runnable whileTrue​(BooleanSupplier terminationCondition)
      Parameters:
      terminationCondition - The condition upon which to terminate.
      Returns:
      A version of this Runnable that calls the run() method repeatedly until the given BooleanSupplier returns false. If the BooleanSupplier returns false on its initial test, the run() method will never be called.