Class RunnableChain

  • All Implemented Interfaces:
    java.lang.Runnable

    public class RunnableChain
    extends java.lang.Object
    implements java.lang.Runnable
    A class to chain multiple runnables to later be run together, within the same thread. When constructed with RunnableChain(boolean, Iterable) the iterator is not requested until execution is starting. This can allow you to delay knowing which tasks to execute until execution is starting.
    Since:
    5.40 (existed since 1.0.0 under package org.threadly.concurrent)
    • Constructor Summary

      Constructors 
      Constructor Description
      RunnableChain​(boolean exceptionStopsChain, java.lang.Iterable<? extends java.lang.Runnable> toRun)
      Constructs a runnable chain with an Iterable.
      RunnableChain​(boolean exceptionStopsChain, java.lang.Runnable... runnables)
      Constructs a runnable chain with a provided array of runnables to iterate over.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void run()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RunnableChain

        public RunnableChain​(boolean exceptionStopsChain,
                             java.lang.Runnable... runnables)
        Constructs a runnable chain with a provided array of runnables to iterate over.
        Parameters:
        exceptionStopsChain - true to allow uncaught exceptions to propagate and stop chain execution
        runnables - Runnables to execute in chain
      • RunnableChain

        public RunnableChain​(boolean exceptionStopsChain,
                             java.lang.Iterable<? extends java.lang.Runnable> toRun)
        Constructs a runnable chain with an Iterable. The provided Iterable wont be requested for Iterable.iterator() until execution is about to start. This can allow a lazy decision for what runnables should be executed.
        Parameters:
        exceptionStopsChain - true to allow uncaught exceptions to propagate and stop chain execution
        toRun - Iterable collection of runnables to run
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable