Home Discussion Discuss: Scheduling a Timer Task

  • Regarding Expected outputMichaelSmith August 25, 2011 at 1:47 PM

    This CertainAndRepeatTime is not working as expected. pls check it out.

  • any programmerHailu Beshada January 9, 2012 at 6:18 PM

    please I want to get source code for classroom scheduling system in java.

  • Problem with Scheduling a Timer Task programKAMAU NG'ANG'A GAKANGA January 14, 2012 at 3:21 PM

    Hi, A've ran the Timer Task program and it is not executing as i expected.I have marked the piece of code which is not executing using ==== in the code below import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Timer; import java.util.TimerTask; public class CertainAndRepeatTime { public static void main(String[] args) throws IOException { int delay = 3000; Timer timer = new Timer(); System.out.println("What do you want (Certain time or Repeat time)?"); System.out.print("Please enter \'C\' or \'R\' for that: "); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String ans = in.readLine(); if (ans.equals("C") || ans.equals("c")) { timer.schedule(new TimerTask() { //======= public void run() { System.out.println("This line is printed only once."); } }, delay); } else if (ans.equals("r") || ans.equals("R")) { timer.schedule(new TimerTask() { public void run() { System.out.println("This line is printed repeatedly."); } }, delay, 1000);//================= } else { System.out.println("Invalid Entry."); System.exit(0); } System.exit(0); } }

  • Doesn't workSomeone June 25, 2012 at 1:10 PM

    Does not work!

  • nonemaurice October 2, 2012 at 5:38 AM

    none moment

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
Java Beginners

j2me timer and timer task
j2me timer and timer task  have anyone idea to change a direction of bubble, according to changing time.   Please go through the following links: http://www.roseindia.net/j2me/timer-midlet.shtml http 

Java Beginners

Java Timer Task
Java Timer Task  How to assign a task in java at specified date & time (with seconds) using threads 

Java-Tutorials

Scheduling a Timer Task
Scheduling a Timer Task       In this section, you can learn how to schedule a timer task to run... the timer task at a certain time means the task will work only once while you 

Java Beginners

Timer and TimerTask
Timer and TimerTask  i have problem of java.lang.IllegalStateException: Task already scheduled or cancelled 

Java Beginners

Java Timer
Java Timer  Hai Sir, I want to know How to schedule a task on first date of every month in java by using Java timer.Please help me sir. thank you, Shyam 

J2ME

J2ME Timer MIDlet Example
J2ME Timer MIDlet Example       This Example shows how to use of timer class. In this example we are using the Timer class to create the time of execution  of application 

SQL Question

task
 

J2ME

J2ME Timer Animation
J2ME Timer Animation       This application illustrates how to use the Timer class..., which helps you to understand using of timer class for drawing the canvas 

General

Task Scheduling in JAVA
Task Scheduling in JAVA       In some applications some task need to run periodically... scheduled time. We can define action to be performed by this timer task 

Java Beginners

Java timer
Java timer  Hi. I want to use a timer in one of my java projects... java.util.Timer; import java.util.TimerTask; public class ToDo { Timer timer; public ToDo ( int seconds ) { timer = new Timer 

JavaScript Questions

timer using javascript
timer using javascript  How to display timer on HTML page using JavaScript 

Java Interview Questions

Difference between Timer and Thread?
Difference between Timer and Thread?  Can anyone tell me about the difference between Timer and Thread, Why we need to have Timer in case we have Thread implimentation startegy in Java 

JSP Servlet Questions

code for timer in java netbeans for online test series countdown timer
code for timer in java netbeans for online test series countdown timer  code for timer in java netbeans for online test series countdown timer 

Java Beginners

Insertion Sort Timer
Insertion Sort Timer  Welcome all I wanna program in java find the timer of insertion sort and find time complexity for random value thanks all 

Swing AWT

Timer - Swing AWT
Timer  How can I make a simple countdown timer in my GUI?  ... { ProgressMonitor progress; static int counter = 0; Timer timer...("Progress bar timer Demo"); setSize(250, 100); setDefaultCloseOperation 

JavaScript Questions

javascript timer countdown
javascript timer countdown  How to disable/enable the javascript timer countdown?   <!-- CSS Code --> #txt { border:none; font... = "yourpage.htm" // redirects to specified page once timer ends and ok button 

Date Calendar

Countdown timer to show a link
Countdown timer to show a link  Hi to everyone! I have this code, which is basically a countdown widget...what I want is that when the countdown finish, a link appears. The thing is that my musical group will be presenting an EP 

Java Interview Questions

Java task scheduling
Java task scheduling  What is a task?s priority and how is it used in scheduling 

Java Interview Questions

Java task scheduling
Java task scheduling  What is a task?s priority and how is it used in scheduling 

Java Beginners

Timer in the code - Java Beginners
Timer in the code  This is the question I posted yesterday: "I'm trying to write a program that has a text field for input, two buttons and the output text area. A user is asked to type in a number. The first button when pressed 

Programming Tutorials

JavaScript Clock Timer
JavaScript Clock Timer...; In this section, we are going to show you a clock timer using JavaScript... than 9, then it will add 0 in front of min, sec or hour value like 09 in the timer 

JSP Servlet Questions

Servlet and Timer - JSP-Servlet
 

Java Beginners

task 2 - Java Beginners
task 2  Write a time server that follows the time protocol outlined in RFC 868. When a client connects, the server sends a 4-byte, big-endian, unsigned integer specifying the number of seconds that have passed since 12:00 A.M. 

Servlets-Tutorials

ServletContextListener with Timer
In this section, you will learn how to use timer with ServletContextListener to run code snippet after every 1 minute immediate after the application run 

Mobile Applications Questions

Registration timer expired, but client is still registering!
Registration timer expired, but client is still registering!  Registration timer expired, but client is still registering 

Java Beginners

task 1 - Java Beginners
task 1  Please write a Java client that send a small letters string to a Java server which convert it to uppercase letters and send it back to the client. Please submit both the client and server programs  Hi Friend 

Java Beginners

java hello and timer alert application
java hello and timer alert application  Hi, Please help me create a simple Java application that can display "Hello world" and current Time alert on mobile device screen using mobile screen emulator. Regards 

Java Beginners

Java + Timer concept - Java Beginners
Java + Timer concept  sir, I am using swing based model. My form... interval) and retrieve values and print it in console. I want code using timer... label; JProgressBar pb; Timer timer; JButton button; public 

JSP Servlet Questions

Retrieval data from database against timer
Retrieval data from database against timer  Please send me a sample timer code which retrieve data from the database against timer in JSP 

Java Beginners

Solving task 1 by 1 from bundle of task data
Solving task 1 by 1 from bundle of task data  Hello and namaste guys... of row.row means task.in each task, there will be an information like userid, Taskid, user_input i have to use the information for eash task to solve the task 

DMCA.com