fitgoodies-core/src/main/java/de/cologneintelligence/fitgoodies/util/WaitForResult.java
public void wait(Object target, Method method, long maxTime, long sleepTime) {
        long remaining = maxTime;

        lastCallWasSuccessful = invokeMethod(target, method);
        while (!lastCallWasSuccessful && remaining > 0) {
            systemTime.sleep(sleepTime);
            remaining -= sleepTime;
            lastCallWasSuccessful = invokeMethod(target, method);
        }

        lastElapsedTime = maxTime - remaining;
    }
public void wait(Object target, Method method, long maxTime, long sleepTime) {
        long remaining = maxTime;

        lastCallWasSuccessful = invokeMethod(target, method);
        while (!lastCallWasSuccessful && remaining > 0) {
            systemTime.sleep(sleepTime);
            remaining -= sleepTime;
            lastCallWasSuccessful = invokeMethod(target, method);
        }

        lastElapsedTime = maxTime - remaining;
    }
Invokes the method multiple times, either until it returns true, or
until maxtime is over. After each invoke, the class waits
{@code sleepTime} milliseconds.

@param target    Object which receives the call.
@param method    Method to invoke on {@code target}.
@param maxTime   Maximum time to wait before causing a failure.
@param sleepTime Time to sleep between method calls.