Here you can find the source of repeatedlyTry(Callable
public static <T> T repeatedlyTry(Callable<T> task, int maxRounds, long backoff) throws Exception
//package com.java2s; //License from project: Open Source License import java.util.LinkedList; import java.util.List; import java.util.concurrent.Callable; public class Main { public static <T> T repeatedlyTry(Callable<T> task, int maxRounds, long backoff) throws Exception { List<Exception> list = new LinkedList<Exception>(); int round = 0; while (round++ < maxRounds) { try { return task.call(); } catch (Exception e) { list.add(e);/*from w w w . ja v a2 s . com*/ try { Thread.sleep(backoff); } catch (InterruptedException e1) { e1.printStackTrace(); } } } throw new Exception("can't run: " + list); } }