java - How to do a timer listener? -
this question has answer here:
- how set timer in java? 5 answers
i new java , want make program execute determined actions if time detected.
example: start timer, when 30 segs have gone, display message, after 3 minutes have gone, execute action, etc, etc.
how can this?
thank you
use timer class, can this:
public void timer() { timertask tasknew = new mytask(); timer timer = new timer(); /* scheduling task, first argument task performing, second delay, , last period. */ timer.schedule(tasknew, 100, 100); }
}
this example of class extends timertask , something.
class mytask extends timertask { @override public void run() { system.out.println("hello world timer task!"); } }
for further reading
Comments
Post a Comment