class Operations {

    public static  void doWithRetries(
            Runnable action,
            int numberOfRetries,
            int sleepInMillisec
            ){
            int triesLeft = numberOfRetries;
            while (true) {
                try {
                    action.run();
                    return;
                } catch (Exception|AssertionError e) {
                    triesLeft-=1;
                    if (triesLeft<=0) {
                        throw e;
                    }
                    try {
                        sleep(sleepInMillisec);
                    } catch (InterruptedException intEx) {
                        throw new RuntimeException(intEx);
                    }
                }
        }
    }

}