Package org.threadly.concurrent.wrapper
Class RunnableChain
- java.lang.Object
-
- org.threadly.concurrent.wrapper.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 withRunnableChain(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 anIterable
.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()
-
-
-
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 executionrunnables
- Runnables to execute in chain
-
RunnableChain
public RunnableChain(boolean exceptionStopsChain, java.lang.Iterable<? extends java.lang.Runnable> toRun)
Constructs a runnable chain with anIterable
. The providedIterable
wont be requested forIterable.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 executiontoRun
- Iterable collection of runnables to run
-
-