Created
July 13, 2023 06:52
-
-
Save saswata-dutta/e9a82c0ddb10f7ee9fc974f6690ad18f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FunctionalInterface | |
interface ThrowingConsumer<T, E extends Exception> { | |
void accept(T t) throws E; | |
static <T> Consumer<T> unchecked(ThrowingConsumer<T, Exception> t) { | |
return arg -> { | |
try { | |
t.accept(arg); | |
} catch (Exception ex) { | |
throw new RuntimeException(ex); | |
} | |
}; | |
} | |
} | |
// threads.forEach(ThrowingConsumer.unchecked(Thread::join)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment