473,473 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I schedule a task to run at periodic intervals?

108 New Member
was trying some codes to implement a scheduled task and came up with these codes .
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2.  
  3. class Task extends TimerTask {
  4.  
  5. int count = 1;
  6.  
  7. // run is a abstract method that defines task performed at scheduled time.
  8. public void run() {
  9.     System.out.println(count+" : Mahendra Singh");
  10.     count++;
  11. }
  12.  
  13. }
  14.  
  15. class TaskScheduling {
  16.  
  17. public static void main(String[] args) { Timer timer = new Timer();
  18.  
  19.    // Schedule to run after every 3 second(3000 millisecond)
  20.    timer.schedule( new Task(), 3000);   
  21.  
  22. } }
  23.  
My output :

1 : Mahendra Singh

I expected the compiler to print a series of Mahendra Singh at periodic interval of 3 s but despite waiting for around 15 minutes, I get only one output...How do I solve this out?
Dec 28 '10 #1
1 2284
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
Please see this link for timer class information.
I don't see a listener here.

Regards
Dheeraj Joshi
Dec 28 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mullin Yu | last post by:
How can I do so? Can I write a windows service that will run a bat file when the system shuts down? I want to write a service because I can create a schedule task by Windows Scheduler only when...
1
by: krallabandi | last post by:
Hi, I have a console application written in VB.NET. I schedule the job using windows 2000 scheduler. It is all working fine but, its opening a console when it was running. How to disable the...
6
by: nilesh soni | last post by:
HELLO EVERY ONE ! I HAVE TO SCHEDULED A TASK TO RUN EVERY DAY AT 4PM, TO CHECK THE SIZE OF THE NOTIFICATION LOG FILE , IF IT EXCEEDS 5MB, THEN I NEED TO RENAME THE FILE AND START WITH A NEW ONE...
1
by: Dean Slindee | last post by:
I am writing a VB.Net application that will replace a series of DTS packages. The DTS packages run once a day at a scheduled time automatically. Would this new application be a Windows Service...
1
by: Alan T | last post by:
I have created a scheduled task successfully programmaticall. However, there is something wrong in the process. When the scheduled task is running and stopped, the result was: "0xe0434f4d". I...
1
by: =?Utf-8?B?U3Jpaw==?= | last post by:
Hi, I have a console application which needs to be run at periodic intervals. So, I want to add it in Windows Task Scheduler but at the same time, I need to pass parameters to the Application...
1
by: cvbayot | last post by:
i'm doing a web based application that has a feature of sending sms messages. the process: when a costumer send a text message to the system, the system will send the same message to the assigned...
0
by: Shina35 | last post by:
Hi All, i scheduled a windows task that is running VBS file that run QTP. the script is running once at the time i set and the day after at the same time it's not running although i set it to run...
2
NeoPa
by: NeoPa | last post by:
My server is running Windows 2000 (All latest SPs & updates) and I need to start a job in the early hours with a specific network account and in interactive mode. I have been using the AT command...
6
by: jumbojs | last post by:
I want to call a method in a web page that I want to call every hour on my web application and run the code. I have now Idea of how to do this. Any help would be appreciated. Thanks
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.