Package fr.enedis.chutney.tools
Interface ThrowingRunnable
- All Superinterfaces:
ThrowingSupplier<Void,Exception>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A functional interface representing a
Runnable that can throw an Exception.
It allows wrapping a runnable that may throw a checked exception, making it compatible with functional programming constructs while preserving exception handling.
Usage Example
ThrowingRunnable throwingRunnable = () -> {
if (Math.random() > 0.5) {
throw new IOException("Random failure");
}
System.out.println("Executed successfully");
};
try {
throwingRunnable.run();
} catch (Exception e) {
e.printStackTrace();
}
- See Also:
-
Method Summary
Methods inherited from interface fr.enedis.chutney.tools.ThrowingSupplier
unsafeGet