Package org.apache.bookkeeper.util
Class SafeRunnable
- java.lang.Object
-
- org.apache.bookkeeper.util.SafeRunnable
-
- All Implemented Interfaces:
java.lang.Runnable
,SafeRunnable
public abstract class SafeRunnable extends java.lang.Object implements SafeRunnable
A SafeRunnable implementation.
-
-
Field Summary
-
Fields inherited from interface org.apache.bookkeeper.common.util.SafeRunnable
LOGGER
-
-
Constructor Summary
Constructors Constructor Description SafeRunnable()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SafeRunnable
safeRun(java.lang.Runnable runnable)
Utility method to use SafeRunnable from lambdas.static SafeRunnable
safeRun(java.lang.Runnable runnable, java.util.function.Consumer<java.lang.Throwable> exceptionHandler)
Utility method to use SafeRunnable from lambdas with a custom exception handler.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.bookkeeper.common.util.SafeRunnable
run, safeRun
-
-
-
-
Method Detail
-
safeRun
public static SafeRunnable safeRun(java.lang.Runnable runnable)
Utility method to use SafeRunnable from lambdas.Eg:
executor.submit(SafeRunnable.safeRun(() -> { // My not-safe code });
-
safeRun
public static SafeRunnable safeRun(java.lang.Runnable runnable, java.util.function.Consumer<java.lang.Throwable> exceptionHandler)
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:
-
-