TimerTask

I am Importing TimerTask in follwing Code but getting
superclass not found error
import java.util.*;
class MyTimer extends TimerTask
     public void run()
          System.out.println("sss");
class test1
     public static void main(String[] args)
          MyTimer m=new MyTimer();
          Timer t1=new Timer();
          t1.schedule(m,50);
---------------ERROR--------------------
C:\java_prog>javac test1.java
test1.java:6: Superclass TimerTask of class MyTimer not found.
class MyTimer extends TimerTask
^
test1.java:20: Class Timer not found in type declaration.
Timer t1=new Timer();
^
test1.java:20: Class Timer not found in type declaration.
Timer t1=new Timer();
^
3 errors
and TimerTask class is thet in src file

MyTimer m=new MyTimer();
You are trying to create an object from your timer class but it has no constructor....
You need one of these methods in it....
public MyTimer()
super(); // calls the superclass constructor.
}

Similar Messages

  • How to cancel a Timer from inside a TimerTask ?

    I have a web application with this structure:
    Tomcat starts a servlet and that starts a master thread to run once every 10 minutes,
    that master thread in turn starts any number of individual tasks to run until completion,
    the idea being a "shoot and forget" methodology.
    public class MasterTask extends TimerTask {
    // run once every 10 minutes
    // retrieve a list of actions to do, this is from a database, could be 10 could be 100
    // for each action schedule a TimerTask
    // the reason for using a new Timer each time is that any of the action tasks
    // may take a long time or not, i do not want an individual task to wait
    // for a previous one to finish, therefore each task is put on it's own timer
    // also in order to spread resources somewhat there is an incremental delay
    // so the is some time between the start of each task as there can be many
    Timer timeit;
    int delay = 0;
    for ( ActionTask doit : taskList ) {
    timeit = new Timer();
    timeit(doit,delay);
    delay = delay+200;
    public class ActionTask extends TimerTask {
    // perform whatever actions need to be done inside this individual TimerTask
    // at some point the individual task has completed it's work
    // how do i completely remove it from this location ?
    I know that inside the TimerTask i can call cancel() but that will only prevent it from running again it does not actually remove it completely, it remains in existence and therefore uses up memory. What i need to do is call the cancel() method on the Timer in order to remove both the Timer and TimerTask.
    If i do not do this then the program will just keep creating new Timers until eternity.
    ( or basically until i run out of memory )
    How do i call the Timer.cancel() method from INSIDE the TimerTask ?
    ( Note that both classes are seperate classes/files and not inside the same file or class. )
    thanks,
    Erik
    Edited by: Datapunter on Jul 27, 2009 4:06 PM

    Gotcha,
    the Timer does get cancelled but the TimerTask runs to completion first.
    Was expecting a kill() type effect but that is not what cancel() does.
    Servlet started by Tomcat
    package servlet;
    import java.util.*;
    import javax.servlet.ServletException;
    public class TestServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
        public void init() throws ServletException {
              Timer timeIt = new Timer();
              timeIt.schedule(new timertasks.testmaster(), 0, 10000); // every 10 seconds
    }master task runs every 10 seconds indefinetly,
    and every 10 seconds it starts (kicks off) 2 new tasks.
    package timertasks;
    import java.util.Timer;
    import java.util.TimerTask;
    public class testmaster extends TimerTask {
         public testmaster() {}
         // scheduled to run once every 10 seconds
         public void run() {
              int delay = 0;
              Timer timeit;
              for ( int count = 0; count < 2 ; count++ ) {
                   timeit = new Timer();
                   timeit.schedule(new ActionTask(timeit), delay, 2000);     // every 2 seconds
                   delay = delay + 200;
    }individual timertask, just comment out the timeit.cancel(); to see the difference in effect.
    package timertasks;
    import java.util.Timer;
    import java.util.TimerTask;
    public class ActionTask extends TimerTask {
         private Timer timeit;
         private int runcounter = 0;
         public ActionTask(Timer timeit) {
              this.timeit = timeit;
         // without cancel then values of runcounter should keep rising and more and more tasks should appear
         // with cancel each should run only once
         public void run() {
              System.out.println("before cancel, runcounter="+runcounter);
              timeit.cancel();
              System.out.println("after cancel, runcounter="+runcounter);
              runcounter++;
    }thanks.

  • Java.util.Timer and java.util.TimerTask running threads problem

    Hi,
    I have following scenario.
    1. My thread to send mail has to run at a fixed time interval thus I am using the following method from the Timer class.
    scheduleAtFixedRate(TimerTask object, start time, interval)
    2. My thread in the class checkDBSendEmail that extends TimerTask class reads database and sends mail based on the data received in the run() method.
    3. Whenever I send any mail, I log it into a database table that keeps the record of the emails sent.
    4. i have put it some logic to filter data form data base after that it will sends me unique data. Data should be email to different uses based on the list.
    Now the Problem:
    I am receiving duplicate mails on multiple times.
    Is there anything that I am missing in the following that would help me resolve this problem.
    my Servlet inti method is:

    sorry code is here..........
    public class SchduleTimeEmail extends HttpServlet implements SingleThreadModel{
    public void init( ServletConfig servletConfig ) throws ServletException{
    super.init(servletConfig);
    this.config = servletConfig;
    try{
    // specify in the format as in 12.13.52 or 3:30pm
    initialTime = format.parse( config.getInitParameter("initialTime"));
    delay = HOURS_24;
    RunLogger.addLogger("init first try:"); // log file
    catch( ParseException pe ){
    // Log.sendMessage( Log.MESSAGE_LEVEL_INFO , "[TimerServlet]", "startTime could not be parsed from web.xml file" );
    System.out.println("startTime could not be parsed from web.xml file."+pe);
    initialTime = new Date();
    delay = HOURS_24;
    // Timer Must start combination of 15,30,45,00 min for check schdule
    Date dalayTimeMinSec = new Date();
    int currentMin = dalayTimeMinSec.getMinutes();
    int totalDelayTime = 0;
    if(currentMin%15!=0 || currentMin%15 != 15){
    try {
    int delayMin = currentMin % 15;
    totalDelayTime = (15-delayMin) * 1000 * 60;
    dalayTimeMinSec.setSeconds(0);
    Thread.sleep(totalDelayTime);
    RunLogger.addLogger("Thread go for sleep:");
    } catch (InterruptedException ex) {
    RunLogger.addLogger(ex.toString());
    //Start Timer from this time
    timer = new Timer();
    Calendar time = Calendar.getInstance();
    Calendar timeOfDay = Calendar.getInstance();
    try{
    timeOfDay.setTime(initialTime);
    time.set((Calendar.HOUR_OF_DAY), timeOfDay.get(Calendar.HOUR_OF_DAY));
    time.set(Calendar.MINUTE, timeOfDay.get(Calendar.MINUTE));
    time.set(Calendar.SECOND, timeOfDay.get(Calendar.SECOND));
    Calendar startTimeOfTimer = Calendar.getInstance();
    startTimeOfTimer.add( Calendar.MINUTE, 0 );
    // make sure the first timer doesn't fire before the server starts
    if( time.before(startTimeOfTimer) )
    time = startTimeOfTimer;
    System.out.println("TimerServlet: Timer has been set for " + time.getTime() + " '(" + delay + ")'"); // for checking
    checkDBSendEmail msasTask = new checkDBSendEmail();
    timer.scheduleAtFixedRate( msasTask, time.getTime(), delay );
    catch( Exception e ){
    RunLogger.addLogger(e.toString());
    public void destroy(){
    timer.cancel();
    super.destroy();
    and another class is:..
    public class checkDBSendEmail extends TimerTask{
    public void run()
    // System.out.println("Function run : "+ functionExcuteCount++);
    try{
    // DB Logic as well as send e-mail function call
    catch( Exception ex ){
    RunLogger.addLogger(ex.toString());
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    public String getServletInfo() {
    return "Short description";
    // </editor-fold>
    I also checked the email server settings, and I am sure that the email server is not duplicating the emails.
    this code working correctly on my local machine But in live server it duplicating email and still I am receiving duplicate mails.
    Any help is appreciated.
    Thanks,
    Sharda

  • Using Timer and TimerTask classes in EJB's(J2EE)

    Does J2EE allow us to use Timer and TimerTask classes from java.util package in SessionBean EJB's ( Statless or Statefull )?.
    If J2EE does allow, I am not sure how things work in practical, Lets take simple example where a stateless SessionBean creates a Timer class
    and schedules a task to be executed after 5 hours and returns. Assuming
    GC kicks in many times in 5 hours, I wonder if the Timer object created by survives the GC run's so that it can execute the scheduled tasks.
    My gut feeling says that the Timer Object will not survive.. Just
    want to confirm that.
    I will be interested to know If there are any techiniques that can make
    the usage of Timer and TimeTask classes in EJB's possible as well as reliable with minmum impact on over all performance.

    Have a look at J2EE 1.4. I think they add a timer service for EJBs there...
    Kai

  • HOW TO SHOW JLABEL IN JDIALOG USE TIMERTASK WHILE MAIN CLASS IS SLEEPING?

    I have done a code below and it is working but the only problem is when the main program start to sleep by use Thread.sleep(10000) for 10 secs and it will prompt out a JDialog contain JLabel inside it with message "Please wait.... program is sleeping.". And when the thread ends the JDialog will auto disappear and it back to the main program.
    The problem is:
    When the JDialog appear, it doesn't show the component so I only be able to view the JDialog window without contain any component. I already use container to add the component into JDialog but it still doesn't show. I only be able to see the JDialog window contain empty component when the main window is sleeping.
    How to make the components also appear in the JDialog when the main program is sleeping?
    Below is the code pls have a try:
    import java.util.*;
    import java.lang.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class testThread extends JFrame
    public static java.util.Timer thisTimer;
    public static doTask a;
    public static testThread tT;
    public Container cMain;
    public Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    public JButton exitBtn;
    public JButton startThreadBtn;
    /** Creates a new instance of testThread */
    public static void main(String args[])
    new testThread();
    public testThread()
    //System.out.println("Start to call JDialog");
    tT = this;
    int realW = (int)screenSize.getWidth();
    int realH = (int)screenSize.getHeight();
    int mainW = 500;
    int mainH = 300;
    setBounds((int)((realW-mainW)/2), (int)((realH-mainH)/2), mainW, mainH);
    setVisible(true);
    exitBtn = new JButton("EXIT");
    exitBtn.setBounds((int)((500-100)/2), (int)((300-50)/5), 100, 50);
    exitBtn.addActionListener
    new ActionListener()
    public void actionPerformed(ActionEvent e)
    System.exit(0);
    // WHEN USER PRESS startThreadBtn it will make the application sleep for 15 secs and pop out JDialog window contain JLabel msg wrote "Please wait... program is sleeping"
    startThreadBtn = new JButton("Start Thread");
    startThreadBtn.setBounds((int)((500-100)/2), (int)((300-50)/5*4), 100, 50);
    startThreadBtn.addActionListener
    new ActionListener()
    public void actionPerformed(ActionEvent e)
    try
    System.out.println("Start to call JDialog");
    a = new doTask();
    thisTimer = new java.util.Timer();
    thisTimer.schedule(a, 0);
    System.out.println("Thread start to sleep first 10 secs");
    Thread.sleep(10000);
    System.out.println("Thread start to sleep second 5 secs");
    Thread.sleep(5000);
    System.out.println("Thread Wake Up");
    a.terminate();
    thisTimer.cancel();
    catch(InterruptedException ie)
    ie.printStackTrace();
    cMain = this.getContentPane();
    cMain.setLayout(null);
    cMain.add(exitBtn);
    cMain.add(startThreadBtn);
    public class doTask extends TimerTask
    JDialog infoDialog;
    public void run()
    System.out.println("TASK IS RUNNING");
    int screenWidth = (int)screenSize.getWidth();
    int screenHeight = (int)screenSize.getHeight();
    int w = 300;
    int h = 200;
    infoDialog = new JDialog(tT, true);
    infoDialog.setTitle("Please Wait!!!");
    Container c = infoDialog.getContentPane();
    c.setLayout(new BorderLayout());
    JLabel infoLbl = new JLabel("Please Wait... Program is sleeping!!!", JLabel.CENTER);
    c.add(infoLbl, BorderLayout.CENTER);
    infoDialog.setBounds((int)((screenWidth-w)/2), (int)((screenHeight-h)/2), w, h);
    infoDialog.setVisible(true);
    public void terminate()
    infoDialog.setVisible(false);
    infoDialog.dispose();
    this.cancel();
    }

    LOUD NOISES.

  • Problem with rescheduling the TimerTask object

    Hi friends,
    Here is the code that I am working on right now...
    I am seeing the following output on the console. Could you please fix this issue with the exception.
    I am trying to reschedule the same TimerTask on the same record, but with a differrent interval.
    ==================================================================================================================
    Starting the timer for 1
    Starting the timer for 2
    Starting the timer for 3
    Starting the timer for 4
    Time Left Over: 4002
    java.lang.IllegalStateException: Task already scheduled or cancelled
    Re - Starting the timer for 1 New interval: 11002
         at java.util.Timer.sched(Timer.java:358)
         at java.util.Timer.schedule(Timer.java:170)
         at timers.PurgingRecords.addRecord(PurgingRecords.java:74)
         at timers.PurgingRecords.main(PurgingRecords.java:118)
    I am deleted :-( NODE: 2 temp: 2.0 seqno 3
    I am deleted :-( NODE: 3 temp: 2.0 seqno 3
    I am deleted :-( NODE: 4 temp: 2.0 seqno 3
    ==================================================================================================================
    Program Code.
    ===========
    import java.util.*;
    class ThermNode
         int nodeno;
         double temp;
         int seqno;
         long ts;
         public ThermNode(int n,double t,int sno, long time)
              nodeno = n;
              temp = t;
              seqno = sno;
              ts = time;
         public String toString()
              return "NODE: "+nodeno+" temp: "+temp+" seqno "+seqno;
    public class PurgingRecords
         ArrayList<ThermNode> table = new ArrayList<ThermNode>();
         long active_timeout_interval = 7000;
         Delete [] timers = new Delete[10];
         Timer time = new Timer(true);
         class Delete extends TimerTask
              int node;
              public Delete(int node)
                   this.node = node;
              public void run()
                   purgeEntry(node);
    public PurgingRecords()
         for(int i=0; i<timers.length; i++)
              timers[i] = new Delete(i);
         public void addRecord(int nodeno)
              int index;
              if((index = exists(nodeno)) == -1)
                   table.add(new ThermNode(nodeno,2,3,System.currentTimeMillis()));
                   System.out.println("Starting the timer for "+nodeno);
                   time.schedule(timers[nodeno],active_timeout_interval);
              else
                   long interval = Math.abs(table.get(index).ts - System.currentTimeMillis());
                   System.out.println("Time Left Over: "+interval);
                   table.set(index, new ThermNode(nodeno,4,7,System.currentTimeMillis()));
                   System.out.println("Re - Starting the timer for "+nodeno+" New interval: "+(interval+active_timeout_interval));
                   timers[nodeno].cancel();
                   time.schedule(timers[nodeno],(active_timeout_interval+interval));     
         private int exists(int nodeno)
              int i = -1;
              for(int j=0;j<table.size();j++)
                   if(table.get(j).nodeno == nodeno)
                        return j;
              return i;
         private void purgeEntry(int nodeno)
              int index;
              ThermNode removed = null;
              if((index = exists(nodeno)) != -1)
                   removed = table.remove(index);
                   System.out.println("I am deleted :-( "+removed.toString());
              else
                   System.out.println("Record doesnot exist for "+nodeno);
         public static void main(String[] args)
              PurgingRecords pr = new PurgingRecords();
              try
              pr.addRecord(1);
              Thread.sleep(1000);
              pr.addRecord(2);
              Thread.sleep(1000);
              pr.addRecord(3);
              Thread.sleep(1000);
              pr.addRecord(4);
              Thread.sleep(1000);
              pr.addRecord(1);
              pr.addRecord(5);
              catch(Exception e)
                   e.printStackTrace();
              while(true)
    }

    To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
    db

  • Which is better TimerTask or Thread????

    Hello!
    I have a server-client application. Every client that access the server is assigned a corresponding sleep time (the sleep should be done in a separate thread) before proceeding to their "special task". My problem is for example i have 1000 clients then there will 1000 threads (sleeping threads). That is too much waste resources therefore I want to make a ClientManagerThread object which schedules (using TimerTask) the time the clients will proceed to their corresponding tasks.
    But Im not sure if TimerTask will take the same amount of resources as the "1 client 1 sleep thread" implementation. Can anybody please tell me Which of the 2 is better to use and why? Or maybe any better solutions?
    Thank you in advance!

    Sounds like you need some kind of Thread pooling mechanism. 1000 threads is unnecessarily many IMO. Maybe you could stack 'wakeup' times in a data structure, and have a pool of maybe 20 worker threads that look for jobs that are 'ready', execute them, look for the next job, and so on.
    Would that help any?

  • How to check TimerTask's task is finish??

    Hi, I have two timerTask schedule in two different classes. 1 is every 10sec grab something from database the second 1 is every one hour stop the first schedule and do something then restart the first schedule. My question here is how am i going to know where the task in schedule 1 is finish before i can stop it.... else i'll lost those data in queue if i terminate the process without checking....

    In my earlier message when I said 10SecTimerTask Class I meant to say the class that contains the 10SecondTimerTask. Something like
    class TenSecondScheduleClass {
       TenSecondTimerTask timerTask = null;
    public void killTimerTask(){
       if (timerTask != null) {
          timerTask.cancel();
          timerTask = null;
    public void createTimerTask(){
       if(timerTask == null){
          timerTask = new TenSecondTimerTask();
    The cancel method on the TimerTask class prevents the run method from ever being called again after the current run, if any, completes. This makes the TimerTask useless to all intents and purposes. You would therefore need to create a new TimerTask to replace the cancelled one. The newly created process will be started start and will run  until the next hourly process cancels and replaces it.
    Does this make more sense ?

  • How to create a new thread/TimerTask in oc4j 10.1.2

    Hi,
    I want to create a TimerTask / Thread in oc4j 10.1.2 so its ejb2.0 no Timer Beans.
    I know its not good to create my own custom TimerTask/Threads inside a container, so i looked and i saw that oc4j 10.1.2 has the notion of "2.9.2 Thread Pool Settings" however this refers only to:
    cite:
    +"The worker thread pool contains worker threads used in processing RMI , HTTP and AJP requests, as well as MDB listener threads. These are process-intensive and use database resources. "+
    but i dont do any rmi/http/ajp/mdb i just want a simple java TimerTask or a Thread.
    Can anyone assist me how to achieve this creating of timerTask / threads with oc4j 10.1.2 ejb2.0?
    Thanks

    Hi
    Since the error points to the unavailability of the driver class,can you double check your library claspath entries again.
    I just tried a DB2 connection using the following properties and the connection went through fine:
    Driver class name: com.oracle.ias.jdbc.db2.DB2Driver
    URL: jdbc:merant:db2://<host_name>:50000;DatabaseName=SAMPLE
    Thanks
    Prasanth

  • LDAP client binding failure stops TimerTask thread

    Hi There,
    I try to schedule a TimerTask once ldap binding fails, but the binding failure prevents the TimerTask thread to start. Any idea? or any work around?
    Thanks.
    try{
    ctx = new InitialLdapContext(envs[ctx_idx], null);
    }catch(NamingException ne){
    START();
    public static void start() {
    timer = new Timer();
    timer.schedule(new TimerTask() {
    public void run(){
    System.out.println(".... Visit moniter ....");
    }, 10, 1000) ;
    } // end of start
    ...

    Problem Fixed. Windows XP client did not have WINS server IP address is TCP/IP properties.

  • Error with TimerTask and Random Access File in a Thread

    Hi all,
    Why I have this error?
    unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown at line which contains:
    RandomAccessFile raf = new RandomAccessFile(f, "r");It does not work neither "Add Throws Clause" or "Surrond with Try / Catch"
    I am sending the full Java code. Thanks in advance.
    package voip;
    import java.io.*;
    import java.util.*;
    public class parseRTCP extends Thread {
      int delay = 2000; // delay for 2 sec.
      int period = 5000; // repeat every 5 sec.
      Timer timer = new Timer();
      public void run() {
        row = 0;
        System.out.println("Wait please!");
        timer.scheduleAtFixedRate(new TimerTask() {
          File f = new File("d:\\project\\java\\test.txt");
          RandomAccessFile raf = new RandomAccessFile(f, "r");
          public void run() {
            Calendar cal = new GregorianCalendar();
            int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23
            int min = cal.get(Calendar.MINUTE); // 0..59
            int sec = cal.get(Calendar.SECOND); // 0..59
            System.out.println(hour24 + ":" + min + " " + sec + "s");
              String line = "";
              // Read all the text file
              try {
                while ( (line = raf.readLine()) != null) {
                  System.out.println(line);
              catch (IOException ex) {
        }, delay, period);
    }

    > It's a silly error but I don't know the
    answer.
    See reply #4, or resign yourself to not knowing the
    answer for eternity.I understand what are you meaning.
    >
    In case the hint's not big enough: POST THE EXACT
    TEXT AND STACK TRACE OF THE ERROR MESSAGE WHEN YOU
    TRY TO SURROUND "RandomAccessFile raf = new
    RandomAccessFile(f, "r");" WITH A TRY/CATCH BLOCK.2 error messages:
    illegal start type at line 20 (20:7)
    <identifier> expected at line 42 (42:8)
    line 20 --> try {
    line 42 --> } // end of public void run
    Java code:
    package voip;
    import java.io.*;
    import java.util.*;
    public class parseRTCP
        extends Thread {
      int delay = 2000; // delay for 2 sec.
      int period = 5000; // repeat every 5 sec.
      Timer timer = new Timer();
      public void run() {
        System.out.println("Wait please!");
        timer.scheduleAtFixedRate(new TimerTask() {
          File f = new File("d:\\project\\java\\test.txt");
          try { // ERROR!!
            RandomAccessFile raf = new RandomAccessFile(f, "r");
          } // end of try
          catch (FileNotFoundException ex) {
          } // end of catch
          public void run() {
            Calendar cal = new GregorianCalendar();
            int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23
            int min = cal.get(Calendar.MINUTE); // 0..59
            int sec = cal.get(Calendar.SECOND); // 0..59
            System.out.println(hour24 + ":" + min + " " + sec + "s");
            String line = "";
            // Read all the text file
            try {
              while ( (line = raf.readLine()) != null) {
                System.out.println(line);
              } // end of while
            } // end of try
            catch (IOException ex) {
            } // end of catch
          } // end of public void run ERROR!!
        }, delay, period); // end of TimerTask
      } // end of public void run
    } // end of public class>
    Or have you not tried that yet?I have tried.
    Your replies and time so far are much appreciated (the same for
    everyone else who has helped),
    Many thanks,
    David

  • Multiple timertasks--Please help

    Hi
    Got a problem here.
    I want to poll some devices on a periodic basis.
    The polling interval for each of these devices will differ.
    So how do I achieve this?
    If I create a Timertask for each of these devices,then I would be creating too many threads ,which will clog my system eventually if I get too many requests to poll multiple devices.
    Please give me a solution as to how I should implement this functionality.
    I read on the net that Using the same Timer with multiple timertasks will anyway create only a single thread..but I am not in a position to know how many timertasks I will have to create before I start off the timer..
    Can anybody pleeeeeeeeease help??
    Early reply will be appreciated.....
    Regards

    yes, TimerTask only spawns 1 thread.
    Timertask will be adequate for your needs. (the best solution(in terms of performance) would be to write your own scheduler.)
    rob,

  • Problem with TimerTask/Timer

    Hy,
    I have a class X which extends TimerTask and a class T which extends Timer.
    What I want is to modify the scheduling of the Timer. So, in my class X I've called the cancel() so as to stop the timer, then create a new Timer and finally called the schedule method of Timer with appropriate parameters. The parameters of the schedule method are (this, delay, period). But I got an IllegalStateException when calling the schdule method since I've already called the cancel method of TimerTask.
    How can I modify the scheduling of a Timer?? please help
    thanks in advance

    How can I modify the scheduling of a Timer??You can't. You must instantiate another TimerTask to be scheduled.

  • How do i actually correctly implement my TimerTask()

    public String randomGenerate(){
         Random random = new Random();
         int myInt = random.nextInt(10);
         myRandom = String.valueOf(myInt);
         return myRandom;
    //### We Love TimerTask! ###
    private void timerTasking(){
              try{
              //trying use randomGenerate
              timerTasking = new timerTasking();     
              img0 = Image.createImage("/"+randomGenerate()+".JPG");
              }catch(Exception ex){}
             zero.setImage(img0,90,83);
    }how do i actually do the right thing for my timerTask()
    i want to make my timerTask as a method , which will be execute at public void run , delay 1 second and interval 5 seconds

    http://support.apple.com/kb/PH2698
    or if you're still on MobileMe:
    http://docs.info.apple.com/article.html?path=MobileMe/Help/en/mmfc0f2442.html
    Regards.

  • How to initialize a WebBean in a TimerTask class

    I have a scheduler, it will trigger a task by using the class "java.util.Timer" within a specific period. The timer can schedule a task that extends the class "TimerTask". The scheduled task should initialize a web-bean called as "Task1" to active the user. (The source code is attached)
    My problem is that when I initialize the web-bean "Task1", the error occurs. I catched the exception message, but it is NULL.
    I want to know that it is possible to initialize the web-bean in a class that extends TimerTask? If yes, how?I have done a test that is I can initialize a web-bean in simple java class by passing the page context to it. In this case, I have passed the page context to the class "ScheduleTask", but failed.
    Thank you in the advance!
    public class ScheduleTask extends TimerTask {
    PageContext pageContext = null;
    public ScheduleTask (PageContext page) {
    this.pageContext = page;
    public void run() {
    try {
    doTasks(pageContext);
    } catch (Exception e){
    throw new RuntimeException(e.getMessage());
    public void doTasks(PageContext page) {
    Task1 t1= new Task1();
    t1.initialize(page, "Task_AppModule.TaskVO");
    t1.setReleaseApplicationResources(true);
    t1.activateUser();
    **********************************************************************************

    Any JDeveloper team member can solve my problem.
    Because our system will be deployed for the production soon, this is the critical problem in my part. I hope I can get the help from you. Thank you very much!

Maybe you are looking for

  • Is there a way to open a playlist in a second window in iTunes 11 - like all previous versions of iTunes could?

    Is there a way to open a playlist in a second window in iTunes 11 - like all previous versions of iTunes could? To build a playlist, I would open a newly created one in a separate window, then in the main widow I would roam through the full music col

  • Updating one varray  column in a table

    Hi , We are using 10gR2 on AIX . I have one varray column in a table which has be updated ..To update this column , data is fetched in a query by using 2 tables.Is there any way to reduce the update time? Edited by: Minu on 25-Apr-2011 20:24

  • Which memory for MBP 2.16, Core 2 Duo

    If this has been answered before than just point me in the right direction. I now have a MBP and am contemplating going to higher memory . That said the local apple store says use there memory, or ramjets ? OK, and to stay away from 3rd party memory,

  • Broadband is unacceptable!!!! i want to leave NOW!...

    i have had bt vision for 5 months i thought i was getting a good service. everything was a hunky dory for about a month untill i started to get V04 error this is due to the fact that my internet isnt quick enough. i also have a problem which online g

  • Combobox values based on query

    I created combobox but how can I set its record source to be based on a query ?