?
Solved

Java timer example

Posted on 2007-10-02
4
Medium Priority
?
21,324 Views
Last Modified: 2013-12-22
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,
0
Comment
Question by:ambuli
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 600 total points
ID: 20000622
0
 
LVL 92

Assisted Solution

by:objects
objects earned 400 total points
ID: 20002756
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20004322
:-)
0
 

Expert Comment

by:jekewa
ID: 20430400
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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question