import java.util.Timer; import java.util.TimerTask; public class SynchroTimerTask extends TimerTask{ private int count=23; private Timer timer; public SynchroTimerTask (Timer timer){ this.timer=timer; } /* * 执行 * */ @Override public void run() { count++; System.out.println("第"+count+"期"); try { TestSSC.timeTaskSSC(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if(count==96){ timer.cancel(); System.out.println("白天----定时任务停止"); } System.out.println("======================================================================="); } }