自己写的一段重试代码

public class TestRetry {

	public static void main(String[] args) {
		retry(5);
	}
	
	private static void retry(int maxCount) {
		int count = 0;
		boolean result = false;
		do {
			count++;
			System.out.println("count="+count);
/*			if(count==2) {
				result = true;
			}*/
		} while (count<maxCount && result == false);
	}
}

原文地址:https://www.cnblogs.com/lcchuguo/p/3991072.html