1 22 package org.objectweb.petals.tools.jbicommon.util; 23 24 import java.util.Timer ; 25 import java.util.TimerTask ; 26 27 34 public abstract class PeriodicTask extends TimerTask { 35 36 39 protected Timer timer; 40 41 44 protected long period; 45 46 49 protected long delay; 50 51 54 private static final long DEFAULT_PERIOD = 1000L; 55 56 60 public PeriodicTask() { 61 this(DEFAULT_PERIOD, DEFAULT_PERIOD); 62 } 63 64 70 public PeriodicTask(long delay, long period) { 71 this.delay = delay; 72 this.period = period; 73 timer = new Timer (); 74 } 75 76 80 public void startProcessing() { 81 timer.schedule(this, delay, period); 82 } 83 84 88 public void stopProcessing() { 89 timer.cancel(); 90 } 91 } 92 | Popular Tags |