Last active
March 4, 2024 21:39
-
-
Save isicju/ca53c0eaf4e5be96d0488e2fae338351 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
Допустим есть функция: | |
public boolean doSomething(){ | |
return System.currentTimeMillis() % 2 == 0; | |
} | |
Напишите функцию doSomethingWithRetry которая пытается вызвать doSomething(). Если doSomething() возвращает false тогда ваша функция | |
должна попробовать вызвать её еще раз пока та не вернет true. Функция получает на вход максимальное количество | |
попыток и ожидание между попытками например 1 секунду. Если все попытки закончились то функция должна вернуть false. | |
public boolean doSomethingWithRetry(int attempts, int secondsBetweenAttempts) { | |
// return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Retry(Retry(Retry :)))