`

方法retry的编写实践版

 
阅读更多
package com.snda.sysdev.virtualsys;

/**
 * @author chengyongchun
 * @date 14-3-21 下午2:54
 */
public class RetryTest {

    public static int retryCount = 3;

    public static void retry() throws Exception{
        int tries = retryCount;
        while (true){
            tries--;
            try{
                System.out.println(tries);
                System.out.println(tries/0);
                break;
            }catch (Exception e){
                if(tries<1){
                    throw e;
                }
            }
        }
    }

    public static void main(String args[]) throws Exception{
        RetryTest.retry();
    }
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics