public void execute(int hour){ long t1 = System.currentTimeMillis(); while(true){ long t2 = System.currentTimeMillis(); if(t2-t1 > hour*60*60*1000){ break; }else{ //TODO your work } } }
写个计时的,到时间就停止