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

Similar Messages

  • Problems with software the update with Nokia 6233

    Problems with software the update with Nokia 6233
    Hello,
    I have so far some-paints tries my software to update.
    Each time the update procedure begins, sometime stands then on the telephone “test mode”.
    On the computer wars I the reference in the update manager “connection to the telephone broken off” and wants the update to again start.
    If I change my profile attitudes since that for example, then after a telephone restart again deleted.
    What there can I make?
    GreetingsMessage Edited by adisaily on 24-Aug-2007 09:03 AM

    It sounds like your 5800 has the earpiece fault that was common with 5800's made before February.
    You need to take it to a nokia care point for repair under warranty.
    Care points/service centres and repair info:
    UK • Europe • Asia-Pacific • USA •
    Canada • Middle East and Africa
    Elsewhere: Click here, select your country, go to the support section, then select repair.

  • I can not do the update , what should I do to fix this error ? "There was a problem with downloading the file . For tips on troubleshooting , please go to Customer Support . ( Error code : 204 ) ." thanks

    I can not do the update , what should I do to fix this error ?
    "There was a problem with downloading the file . For tips on troubleshooting , please go to Customer Support . ( Error code : 204 ) ." thanks

    Hi,
    Please refer to the help document below:
    Error downloading, installing, or updating Creative Cloud applications
    Regards,
    Sheena

  • Problem with running the midlet class (Error with Installation suite )

    hi everyone...
    i have problem with running the midlet class(BluetoothChatMIDlet.java)
    it keep showing me the same kind of error in the output pane of netbeans...
    which is:
    Installing suite from: http://127.0.0.1:49296/Chat.jad
    [WARN] [rms     ] javacall_file_open: wopen failed for: C:\Users\user\javame-sdk\3.0\work\0\appdb\delete_notify.dat
    i also did some research on this but due to lack of forum that discussing about this,im end up no where..
    from my research i also find out that some of the developer make a changes in class properties..
    where they check the SIGN DISTRIBUTION...and also change the ALIAS to UNTRUSTED..after that,click the EXPORT KEY INTO JAVA ME SDK,PLATFORM,EMULATOR...
    i did that but also didnt work out..
    could any1 teach me how to fix it...
    thanx in advance... :)

    actually, i do my FYP on bluetooth chatting...
    and there will be more than two emulators running at the same time..
    one of my frens said that if u want to run more than one emulator u just simply click on run button..
    and it will appear on the screen..

  • I purchased Microsoft Office for Mac through the Apple website.. I have downloaded all from the disk into my Mac, no problem with all the other Word etc, but Outlook is asking for the key number: I have put it in but its obviously not the right one...????

    I purchased Microsoft Office for Mac through the Apple website.. I have downloaded all from the disk into my Mac, no problem with all the other Word etc, but Outlook is asking for the key number: I have put it in but its obviously not the right one...???? In the box with the disk came the product key, have put it in and it doesnt work. Please help..x

    unfortunately - you can not.  you can't even buy outlook by itself at microsoft's own website.
    does it have to be outlook?  maybe you can get away with using something else that's outlook compatible.
    how about trying Thunderbird for Mac OS?
    or maybe you can call apple and let them know you purchase the wrong version - they might give you a break and just pay the difference for the home and business version.
    good luck

  • I have a problem with loading the PNG image

    I have a problem with loading the PNG image from site. For ex. go to icefilms com and is starts to load png like crazy CPU is huge and you can not shut down Firefox at least a minute. This is not just in this site but whit any one whit lots of pictures.
    Image from firefox: Picture [http://img836.imageshack.us/img836/9910/7312011103147pm.jpg 1] [http://img28.imageshack.us/img28/8505/7312011103249pm.jpg 2] [http://img706.imageshack.us/img706/5615/7312011103348pm.jpg 3 ][http://img827.imageshack.us/img827/8483/7312011103533pm.jpg 4]
    This is my Task Manager [http://img217.imageshack.us/img217/5715/7312011103621pm.jpg 1]
    - I try safe mode, same thing
    -All addons and plugins are ok
    Any idea why is this so big problem.

    i did both of them, but still the while sending the mail the diolog box is not showing up and also the spelling and grammer does not do the spelling check. 
    This problem just started for about 3 to 4 days now.  earlier it was working normally.

  • Problem with mapping the Entity beans onto database tables

    Hi,
    I got a problem with mapping the Entity beans onto database tables. Here are what I did:
    First Step:
    asant capture-schema
    Second Step:
    capture-schema -driver com.pointbase.jdbc.jdbcUniversalDriver -dburl jdbc:pointbase:server://localhost/sun-appserv-samples -username pbPublic -password pbpublic -table APPLICANT -table APPLICANTSKILL -table CUSTOMER -table LOCATION -table job -table JOBSKILL -table SKILL -out build/agency.dbschema
    The first step was fine. But, in the second step, I got the error message as follow:
    using dburl:jdbc:pointbase:server://localhost/sun-appserv-samples
    using username:pbPublic
    using password:pbpublic
    using driver:com.pointbase.jdbc.jdbcUniversalDriver
    using schemaname:null
    using output file:build/agency.dbschema
    JDO71100: Failed to find a class. Verify that the class is available on your CLASSPATH
    java.lang.ClassNotFoundException: com.pointbase.jdbc.jdbcUniversalDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:141)
    at com.sun.forte4j.modules.dbmodel.jdbcimpl.ConnectionProvider.<init>(Co
    nnectionProvider.java:38)
    at com.sun.jdo.api.persistence.mapping.ejb.CaptureSchema.main(CaptureSch
    ema.java:130)
    at com.sun.jdo.spi.persistence.support.ejb.util.CaptureSchemaWrapper.mai
    n(CaptureSchemaWrapper.java:29)
    Thanks for your help!

    You need to add the pbclient.jar or some similar name like that, in the CalssPath.

  • I am having problem with using the Basic brush definition

    I am having problem with using the Basic brush definition. When I try to click on it will not allow me to use it and will automatically use the 5 pt. oval brush definition. The only way I can use the basic brush is after I have already drawn something and then I have to click on the stroke and then press basic. This is incredibly annoying and if anyone could help I would greatly appreciate it. (I have Adobe CS6)

    for whatever reason, the basic 'brush' you see in the brushes palette effectively means removing any brush from a path. to draw with the brush tool you need a brush defined. in your case the last one selected being the 5 pt oval one.

  • Problem with getting the little blackberry icon

    Hi the blackberry I'm using is working and up to date. I was setting up my mates blackberry 9320 but having a problem with getting the little blackberry icon to appear in the top right corner of my phone where the GMS is and signal bar and stuff its something to do with blackberry.
    I tried downloading bbm and it say associating bbm with blackberry id and constant loads with nothing happening bbm not working
    I NEED THE TINY BB ICON AT TOP RIGHT???

    Hi neal123
                            That BlackBerry icon will appear near signal bar when we activate  BIS on a 3G device. Did he activated BIS on his account. ? 
    Click " Like " if you want to Thank someone.
    If Problem Resolves mark the post(s) as " Solution ", so that other can make use of it.

  • Problems with downlowding the latest version of iTunes

    Resently there have ben problems with downloading the latest versions of iTunes.
    And also the version 10.6.1.7 I had to reinstall up to four times, undtil the install
    succeeded.
    Normally the updates are running without any problems.
    I have ben iTunes customer several years, and very satisfied with the program.
    Best regards
    Aagevi

    Try downloading iTunes directly from the Apple website -> http://www.apple.com/itunes/download/

  • I have a problem with Transport the personalization of standard ess compone

    I have a problem with Transport the personalization of standard ess component.
    My problem is in several components, such as:
    portal_content/com.sap.pct/every_user/com.sap.pct.erp.ess.bp_folder/com.sap.pct.erp.ess.roles/
    com.sap.pct.erp.ess.employee_self_service/com.sap.pct.erp.ess.employee_self_service/
    com.sap.pct.erp.ess.area_personal_information/persinfo_es/com.sap.pct.erp.ess.13.pdata
    I have personalized this page (into rol, not directly in the page), with Ctrl+Right button.
    Now i transport the rol, from Development to Quality environment, but i don't see the changes in Quality.
    My system is NW 7.01 SP7, Can be that the problem?
    Any idea to solve this problem?

    First please see note 1234273 which details how best to personalize
    for all users.
    http://help.sap.com/saphelp_nw04s/helpdata/en/42/ed3ce7f8593eebe10000000
    a1553f7/frameset.htm
    Here you can read:
    "If an iView is transported to another portal all these properties are
    also transported. This is needed to make sure that role-specific changes
    could be transported together with the role. End user personalization
    data is NOT transported in this way as end user personalization is only
    local to the current portal."
    Could you please ensure that personalization was done by an admin user?
    I'm afraid that if it was done by an end user, personalization isn´t
    transported as it's explained in the documentation provided.
    Could you please confirm whether you are using exactly the same language
    to access to both systems, development and quality? Maybe you are using
    language en(us) in one system and en(gb) in the other one. Please take
    into account that personalization is language specific.
    From the web dynpro end, the WebDynpro personalization is stored
    NOT in the PCD prior to 710 release. And as such it cannot be included
    in a portal role transport. This feature is available with NW 7.10 SP2
    or later (from webdynpro point stand). The best option is to
    go with NW 7.30 as this is the first NetWeaver release with EP since
    NW 7.02.

  • Has anyone experience problems with loading the latest Flash Play?

    Has anyone experienced problems with loading the latest Flash Player?  I have done this several times and the same results come up - Install the latest Flash Player.  I run Microsoft Vista.

    What is your browser?  If IE see
    http://forums.adobe.com/thread/885448
    http://forums.adobe.com/thread/867968

  • HT1918 problem with changing the payment information

    I've got a problem with changing the payment information !!
    when I change them and I followed the instruction , and when I click done
    it says " for assistance, contact iTunes support at " the link " . and nothing
    change , so what should I do ?

    Hi Bart,
       The description of the field VBKD-BSTKD will appear in sales order (VA01/02/03) Header  Order data tab.
    If you notice the text for below one it is PO Number where Number starts with upper-case N and it iis not the one which you changed.
    Also this is a hyperlink to sales header order data screen.
    You need to enhance the code via sales exit to fix this.

  • I am getting weary of my iPhone 4s. the battery life is non-existent, second, i had problems with calls, the caller couldn't hear me and now it cannot detect internet networks. Be they wi-fi or cellular. what could be the problem.

    I am getting weary of my iPhone 4s. The battery life is non-existent, secondly, I had problems with calls, the caller couldn't hear me and now it cannot detect internet networks. Be they Wi-Fi or cellular. what could be the problem?

    Mullaly75 wrote:
    I assume u guys don't understand what open source software is
    Yes, I think most of us do understand what open source software is. It sounds as if you don't. Here's some information:
    Open-source software (OSS) is computer software that is available in source code form: the source code and certain other rights normally reserved forcopyright holders are provided under an open-source license that permits users to study, change, improve and at times also to distribute the software.
    Open source software is very often developed in a public, collaborative manner. Open-source software is the most prominent example of open-sourcedevelopment and often compared to (technically defined) user-generated content or (legally defined) open content movements.
    from http://en.wikipedia.org/wiki/Open_source_software
    Yes, Tom Wu of Stanford wrote a paper on something called Secure Remote Access Protocol. It's a form of Asymetric Key Exchange and has nothing to do with hacking anything. It's actually intended to protect data.

  • Hello! The new version of Firefox I have a problem with opening the site VKontakte. The browser displays the following error: "Firefox has determined that the s

    Hello!
    The new version of Firefox I have a problem with opening the site VKontakte. The browser displays the following error: "Firefox has determined that the server redirects the request for this address in a way that it will never end." How to solve this problem? Please excuse me for my English.
    Sincerely, Vsevolod.

    You're welcome

Maybe you are looking for

  • How do i connect an external usb webcam to my macbook air running OSX Yosemite

    i have purchased a bird box with an external USB spy cam. My macbook isn't recognising it. i have downloaded VCR software as recommended by the manufacturer, but it doesnt matter if i open that software or photo booth it only gives the option of the

  • Reinstalling on New Windows 8.1

    I recently purchased a new computer.  It runs Windows 8.1.  I uninstalled all of my Adobe products from my old computer and have had no sucess getting to the downloads section in my Adobe Cloud acount.  I get a blank screen.  I have looked at the var

  • Hyperion S9 Shared Services Error

    Hi All, I have been faced with some problem pertaining to Shared Services 9.3.1 The OpenLDAP services work perfectly fine, but the Shared Services throws an error " Some services stop automaticaly when there is no work to be done " I have done the fo

  • Pausing Captivate 6 with a swf created in Flash Pro

    Not sure why my code isn't working but I've tried a few different things based on what's worked for other people. The code is placed on the frame where I need the interaction to pause. None of them appear to be working. I have a custom Flash interact

  • Is it possible to make the compiler driver use a third-party pre-processor?

    In other compiler suites I've used in the past it's been possible to force the compiler driver to use a different pre-processor if it was needed.  Does Sun Studio offer similar functionality? Ultimately what I'm after is finding a way to force the co