我目前面临一个具体问题,我不知道如何解决。我简单描述一下这个问题:
仅使用“老派”意味着我想出了如下的解决方案(部分伪代码以简化)
//No exception handling to simplify method
public ComplexValuePart mainMethod(int id) {
//Other code executed before
int maxAmountTries = 5;
int waitTime = 2000;
int counter = 0;
boolean conditionFulfilled = false;
ComplexValue cv = null;
while (counter++ < maxAmountTries && !conditionFulfilled) {
cv = calculatingMethod(id);
if (cv.conditionHolds()) {
conditionFulfilled = true;
} else {
Thread.sleep(waitTime);
}
}
if (counter == maxAmountTries …Run Code Online (Sandbox Code Playgroud)