@FunctionalInterface public interface ThrowingRunnable extends Runnable
ThrowingRunnable
s can throw any kind of Exception
. When used
as Runnable
exceptions are hidden from compiler.
This is a functional interface whose
functional method is runThrowing()
.
Modifier and Type | Method and Description |
---|---|
default void |
run()
Runs this runnable, allow throwing any kind of
Exception . |
void |
runThrowing()
Runs this runnable, allow throwing any kind of
Exception . |
static Runnable |
throwing(ThrowingRunnable runnable)
Short-hand method to cast any
ThrowingRunnable as Runnable . |
static Runnable throwing(ThrowingRunnable runnable)
ThrowingRunnable
as Runnable
.runnable
- throwing runnabledefault void run()
Exception
.
As this hides exceptions from the compiler, the calling method should either:
throws
statement for the hidden exceptions
catch
@throws
.
run
in interface Runnable
SneakyException
- hidden exceptionsCopyright © 2025. All rights reserved.