Created
November 6, 2019 02:59
-
-
Save cshijiel/c8021da3ab8680e7b5aabc033c54a472 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public <T> void retryAction(Supplier<T> task, Predicate<T> predicate, Consumer<T> after, int retryTimes) { | |
for (int i = 0; i < retryTimes; i++) { | |
T res = task.get(); | |
log.info("retry result {}", res); | |
if (predicate.test(res)) { | |
after.accept(res); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment