In this section, you can learn how to schedule a timer task to run at a certain time and repeatedly. There is an example given for the illustration. This program asks you for the way of performing the task whether at the certain time or repeatedly. If you enter the "c" then the program will perform the timer task at a certain time means the task will work only once while you enter the "r" then the program performs the timer task repeatedly until you terminate the program.
Code Description:
This program has used the following method for the appropriate:
Timer.schedule():
Above method of Timer class sets the schedule for the specific task. In
this program, this method has been used two times. First time two parameters
have passed through the method as follows:
Second time three parameters have passed to the method which are explained as follows in which explanation of of the first two arguments are given above and the third is as:
Here is the code of the program:
import java.util.*;
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Scheduling a Timer Task View All Comments
Post your Comment