Java-Timer and TimerTask (Another Example)
Program Program Source import java.util.Timer; import java.util.TimerTask; class TimerT extends TimerTask { float time = 3; public void run() { System.out.println(“time = “+time); time-=.50; } } public class Javaapp { public static void main(String[] args) { TimerT task = new TimerT(); Timer time = new Timer(); time.schedule(task,2000,500); try{ Thread.sleep(5000); }catch(InterruptedException ie) { System.out.println(“Thread Interrupted”); } … Read more…