Java timer example

Hi Experts,

I need to have a timer that fires up an event when the specified time is elapsed. How can I do this.   Please provide a simple example.

Thanks,
ambuliAsked:
Who is Participating?
 
CEHJCommented:
:-)
0
 
jekewaCommented:
The following will start the task after a one-second delay.
new java.util.Timer().schedule(new java.util.TimerTask(){
  public void run(){
    /* your task here */
  }
}, 1000);

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.