package com.changhong.epc.parsing.service.loop.tools.impl; import com.changhong.epc.constter.parsing.loop.LoopServiceConst; /** * 算法工具类 * @author wzx * */ public class AlgorithmTool { /** * 计算服务休眠时间的间隔时间 * @param oldTime 前一次执行的时间 * @param odTime2 * @param sleepTime * @return */ public static long calcServiceGapTime(long oldTime, long currTime, long sleepTime){ long newTime = sleepTime + (oldTime - currTime); // System.err.println("-->newTime "+newTime); if(currTime > LoopServiceConst.SLEEP_MAX_TIME){ newTime = LoopServiceConst.SLEEP_MIN_TIME; } if(currTime < LoopServiceConst.SLEEP_MIN_TIME){ newTime = LoopServiceConst.SLEEP_MAX_TIME; } return newTime; } }