Package dk.gtz.graphedit.util
Class RetryUtils
java.lang.Object
dk.gtz.graphedit.util.RetryUtils
Utility functions for retrying actions multiple times.
-
Method Summary
-
Method Details
-
tryTimes
Try an action until it returns a value or until a set amount of attempts failed.- Type Parameters:
T
- The return type that the function should return.- Parameters:
maxAttempts
- Maximum amount of times to trysleepMillis
- Amount of time to wait between failed attemptsf
- The supplier function to try- Returns:
- The return value of the supplier function f
- Throws:
RuntimeException
- if too many attempts happenned
-
sleep
public static void sleep(int milliseconds) Sleep for a set amount of milliseconds. If interrupted, simply return.- Parameters:
milliseconds
- The length of time to wait in milliseconds
-