Interface SafeRunnable
- All Superinterfaces:
Runnable
- All Known Implementing Classes:
SafeRunnable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A runnable that catches runtime exceptions.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault voidrun()voidsafeRun()static SafeRunnableUtility method to use SafeRunnable from lambdas.static SafeRunnableUtility method to use SafeRunnable from lambdas with a custom exception handler.
-
Field Details
-
LOGGER
static final org.slf4j.Logger LOGGER
-
-
Method Details
-
run
default void run() -
safeRun
void safeRun() -
safeRun
Utility method to use SafeRunnable from lambdas.Eg:
executor.submit(SafeRunnable.safeRun(() -> { // My not-safe code }); -
safeRun
Utility method to use SafeRunnable from lambdas with a custom exception handler.Eg:
executor.submit(SafeRunnable.safeRun(() -> { // My not-safe code }, exception -> { // Handle exception );- Parameters:
runnable-exceptionHandler- handler that will be called when there are any exception- Returns:
-