java - How to do a timer listener? -


this question has answer here:

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

timer docs

timer schedule example


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -