provided by: 
Originally published at Internet.comAmidst all the changes and additions in JDK 1.3, was a small but useful class called Timer. Timer and TimerTask both belong to the java.util package. They facilitate execution of code at a predetermined time or during specified time intervals. In Unix, you can use the "at" command to schedule a process to run at specific times. A similar facility exists under NT servers. There are, however, times when you need to schedule execution of a particular task within a Java program.

Piroz Mohseni
Let's look at a very simple example.
The class ttask inherits from TimerTask and implements a single run() method. Similar to threads, the code inside of the run() method is what is executed on a scheduled basis. In our case, we simply print out a message. Another method that you can implement is cancel(), which stops the task. You only need to call this method once, because after an event is cancelled, it doesn't make sense to cancel it again. You won't get an error, however, if you repeatedly call cancel. It just won't do anything.
Finally, the last method of TimerTask is scheduledExecutionTime(). It returns the scheduled execution time of the task. You can use this value to decide whether you should skip execution or take other actions. If your application requires scheduling and fixed-time execution of tasks, you should take a look at Timer and TimerTask classes...
Read article at Internet.com site