Skip to content

Instantly share code, notes, and snippets.

@lwahlmeier
Created January 5, 2018 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lwahlmeier/f8896b64fee8e2e606929e904b21f348 to your computer and use it in GitHub Desktop.
Save lwahlmeier/f8896b64fee8e2e606929e904b21f348 to your computer and use it in GitHub Desktop.
protected void runListener(Executor executor, boolean throwException, Runnable ...listener) {
try {
if (executor != null) {
executor.execute(()->{
for(Runnable r: listener) {
r.run();
}
});
} else {
for(Runnable r: listener) {
r.run();
}
}
} catch (Throwable t) {
if (throwException) {
throw ExceptionUtils.makeRuntime(t);
} else {
ExceptionUtils.handleException(t);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment