Timer not running...

Please could someone assist me as to why this timer is not running. I've tried using the javax.Timer method and am now using the Thread which implements the Runnable interface.
public class superMarketRun
     public static void main(String [] args)
          superMarket sm = new superMarket();
          //sm.startSim();
}The above start initializes the superMarket object which holds the timer. This is a console program.
import java.awt.event.*;
public class superMarket implements Runnable
     private Thread      mainThread;
     private final int     DELAY = 20;
     public superMarket()
          System.out.println("Initializing supermarket...");
          // organise the thread
          mainThread = null;
          start();
     public void start()
          System.out.println("Starting sim...");
          // organise the thread
          if(mainThread == null)
               mainThread = new Thread(this);
     public void stop()
          mainThread = null;
     public void run()
          Thread myThread = Thread.currentThread();
          while(mainThread == myThread)
               try {
                    System.out.println("debug");
                    mainThread.sleep(DELAY);
               catch(InterruptedException e){}
}I really have no clue why it works. The output I get is:
Initializing supermarket...
Starting sim...
Press any key to continue...In other words the thread is not running as the output "debug" is not being shown.
Any assistance would be greatly appreciated.

I think you should scrap this code and start over with something that just demonstrates the basics. I have a bad feeling about why you implemented start and stop. I also don't like that you used a Swing component instead of java.util.Timer.
Compile and run the following.
public class Test implements Runnable{
  private int delay;
  private boolean stayalive;
  public static void main(String args[])throws Exception{
    Test t = new Test();
    Thread myThread = new Thread(t);
    myThread.start();
    for(int i=0;i<5;i++){
      System.out.println("Hello from main thread!");
      Thread.currentThread().sleep(500);
    System.out.println("Main STOPPING test!");
    t.kill();
    for(int i=0;i<5;i++){
      System.out.println("Hello again from main thread!");
      Thread.currentThread().sleep(500);
    System.out.println("Bye from main thread!");
  public Test(){
    this.delay = 1000;
    this.stayalive = true;
  public void kill(){
    this.stayalive = false;     
  public void run(){
    while(this.stayalive){
      System.out.println("Hello from TEST thread!");          
      try{
        Thread.currentThread().sleep(delay);
      }catch(InterruptedException e){
    System.out.println("Bye from TEST thread!");
}

Similar Messages

  • Count down timer not run in background

    On my 1520, with 8.1, i tried many timer apps and found the timer function failed when running in background. The even happened to the app, SuperTimer, which claimed to have overcame the issue. In Supertimer the countdown lags and even stop at times depending on what other things I am running. Really disappointing. It appears to be an issue wth Windows OS that none of the app programmers could fix.
    Disappointed
    Solved!
    Go to Solution.

    Have you allowed the app to run in background in the battery saver settings?

  • I uninstalled Firefox once, reinstalled it and it ran. I had a problem so I did it again. Now it will not run and I get an error message saying that firefox is running and you can only run one at a time. I can't figure out what is running.

    Because of a problem, I uninstalled Firefox once, reinstalled it and it ran. I had a problem so I uninstalled/reinstalled it again. Now it will not run. I get an error message saying that firefox is running and you can only run one at a time. I have uninstalled multiple times and can't figure out what is running. The is only one Firefox installed and it is not open. What does this mean and how do I fix it?

    If you use ZoneAlarm Extreme Security then try to disable Virtualization.
    *http://kb.mozillazine.org/Browser_will_not_start_up#XULRunner_error_after_an_update
    See also:
    *[[/questions/880050]]

  • I am trying to install a program on my Mac Book Pro Retina from a Apple SuperDrive. Every time I run the installer, it says I do not have enough memory to install. However, I definitely have enough memory (186.74 GB). Any ideas why?

    I am trying to install a program on my Mac Book Pro Retina from a Apple SuperDrive. Every time I run the installer, it says I do not have enough memory to install. However, I definitely have enough memory (186.74 GB). The program takes only 550 MB. Any ideas why?

    Thanks for the clarification on the terms. I consider myself proficent at my computer, but not exactly in its inner-workings! I have 8 GB of memory installed.
    I am still confused as to why I do not have any space for the program. This is the exact error message I get: "There is not enough free space on Macintosh HD disk. The Print Shop 2 application requires about 550 MB to be installed. Free some disk space and try again."
    Thank you again for your help.

  • Real-Time Decision Server is not running

    Hi,
    In the Admin guide for RTD Center, during Initializing the Oracle RTD Database Using SDDBTool, one of the step mentioned is "To check, Real-Time Decision Server is not running" but nothing has been mentioned if this is a Service or we have to check in Weblogic or service panel.
    So the question is, How do I check if my Real-Time Decision Server is running or not? Do I have shut down OBIEE instance for the same?
    Regards,
    Jitendra

    Hi,
    try it like this.
    http://IP:9704/ui/do/logout
    note: bi services should be up.
    Thanks
    Deva

  • Trying to download icloud control panel - only getting so far.  Got message: The installer encountered errors before iCloud Control Panel 2.1.2 could be configured.  Your system has not been modified.  To retry these operations at ltr time, pls run again.

    First time on here... so not sure if doing correctly.
    I'm tryng to download icloud control panel to my PC (have Windows 7 - so should be ok).  I only get so far - 2 times I've tried it.  Keep getting message:
    The installer encountered errors before iCloud Control Panel 2.1.2 could be configured.
    Your system has not been modified. To retry these operations at a later time, please run the installer again.
    huh?

    As I mentioned before you need to start the iTunes installation, then do NOT allow it to complete. In other words go all the way to the point that the installer extract the installation files, then STOP right there.
    Now look for the temp folder and the files I mentioned in my initial posting. If you don't find the temp folder it may be because you have "Do not show hidden files and folder" selected under "View Tab" in the "Folder Options". You may need to unselec it. If you don't know about hidden files and folders in Windows XP take a look here: http://txpress.blogspot.com/2007/05/show-hidden-filesfolders-in-windows.html
    Another possibility is that you may have a different path for your temp folders. To find out where you temp folders are located please do the following:
    - Right click on "my computer"
    - Select the "Advanced" tab
    - Click on "Environment Variables"
    Then look for the path for both variables "TEMP" and "TMP" take note of the path and check them out.
    Or you may just go to a DOS Prompt and type the following commands:
    1 - %temp% and hit enter
    2 - %tmp% and hit enter
    to both of these commands you will get a reply such as:
    'c:\temp' is not recognized as an internal or external command, operable program or bath files.
    So by looking at the reply you can see that my temp folder is c:\temp
    The above is the temp folder on my machine which I've customized to my own use. Your machine may be different.
    I suggest you check for the iTunes temp folder inside both your temp folders locations "TEMP" and "TMP" as they may be in different locations.
    IMPORTANT NOTE: If you allow the iTunes installation to complete you will NOT SEE the iTunes temp folder and files because it will be deleted as soon as iTunes processes the installation.
    Hope it helps.

  • HT1926 My iTunes installer was interrupted & now it's telling me "Your system has not been modified.  To complete these operations at a later time, please run the installer again". The only problem is, I've tried to run it about six or seven times.  Can s

    My iTunes installer was interrupted &amp; now it's telling me "Your system has not been modified.  To complete these operations at a later time, please run the installer again". The only problem is, I've tried to run it about six or seven times.

    I'm not sure anyone here knows more about the Java plugin than you do...
    Were you starting the control panel from disk as administrator because it didn't work starting it through the Start menu (if you have Control Panel set to View by Category, the Java control panel is under "Programs").

  • Help: I want to auto schedule a load using file watcher but it runs only once for the first time and after that it is not running at all

    Hi All,
    I am trying  to execute the below code as provided from one of the blogs. i am able to run the job only once based on a file watcher object(i.e. for very first time) and after that the job is not running at all and if  i schedule the job to run automatically based on interval of 10 or more minutes it is executing properly). Please let me know or guide me if i have missed any step or configuration.that is needed.
    Version of Oracle 11.2.0.1.0
    OS : Windows 7 Prof
    Given all the necessary privileges
    BEGIN
      DBMS_SCHEDULER.CREATE_CREDENTIAL(
         credential_name => 'cred',
         username        => 'XXXX',
         password        => 'XXXX');
    END;
    CREATE TABLE ZZZZ (WHEN timestamp, file_name varchar2(100),
       file_size number, processed char(1));
    CREATE OR REPLACE PROCEDURE YYYY
      (payload IN sys.scheduler_filewatcher_result) AS
    BEGIN
      INSERT INTO ZZZZ VALUES
         (payload.file_timestamp,
          payload.directory_path || '/' || payload.actual_file_name,
          payload.file_size,
          'N');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_PROGRAM(
        program_name        => 'prog1',
        program_type        => 'stored_procedure',
        program_action      => 'YYYY',
        number_of_arguments => 1,
        enabled             => FALSE);
      DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT(
        program_name        => 'prog1',
        metadata_attribute  => 'event_message',
        argument_position   => 1);
      DBMS_SCHEDULER.ENABLE('prog1');
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_FILE_WATCHER(
        file_watcher_name => 'file_watcher1',
        directory_path    => 'D:\AAAA',
        file_name         => '*.txt',
        credential_name   => 'cred',
        destination       => NULL,
        enabled           => FALSE);
    END;
    BEGIN
      DBMS_SCHEDULER.CREATE_JOB(
        job_name        => 'job1',
        program_name    => 'prog1',
        queue_spec      => 'file_watcher1',
        auto_drop       => FALSE,
        enabled         => FALSE);
      DBMS_SCHEDULER.SET_ATTRIBUTE('job1','PARALLEL_INSTANCES',TRUE);
    END;
    EXEC DBMS_SCHEDULER.ENABLE('file_watcher1,job1');
    Regards,
    kumar.

    Please post a copy and paste of a complete run of a test case, similar to what I have shown below.
    SCOTT@orcl12c> SELECT banner FROM v$version
      2  /
    BANNER
    Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
    PL/SQL Release 12.1.0.1.0 - Production
    CORE    12.1.0.1.0    Production
    TNS for 64-bit Windows: Version 12.1.0.1.0 - Production
    NLSRTL Version 12.1.0.1.0 - Production
    5 rows selected.
    SCOTT@orcl12c> CONN / AS SYSDBA
    Connected.
    SYS@orcl12c> -- set file watcher interval to one minute:
    SYS@orcl12c> BEGIN
      2    DBMS_SCHEDULER.SET_ATTRIBUTE
      3       ('file_watcher_schedule',
      4        'repeat_interval',
      5        'freq=minutely; interval=1');
      6  END;
      7  /
    PL/SQL procedure successfully completed.
    SYS@orcl12c> CONNECT scott/tiger
    Connected.
    SCOTT@orcl12c> BEGIN
      2    -- create credential using operating system user and password (fill in your own):
      3    DBMS_SCHEDULER.CREATE_CREDENTIAL
      4       (credential_name     => 'cred',
      5        username          => '...',
      6        password          => '...');
      7  END;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- create table to insert results into:
    SCOTT@orcl12c> CREATE TABLE ZZZZ
      2    (WHEN      timestamp,
      3      file_name varchar2(100),
      4      file_size number,
      5      processed char(1))
      6  /
    Table created.
    SCOTT@orcl12c> -- create procedure to insert results:
    SCOTT@orcl12c> CREATE OR REPLACE PROCEDURE YYYY
      2    (payload IN sys.scheduler_filewatcher_result)
      3  AS
      4  BEGIN
      5    INSERT INTO ZZZZ VALUES
      6        (payload.file_timestamp,
      7         payload.directory_path || '/' || payload.actual_file_name,
      8         payload.file_size,
      9         'N');
    10  END;
    11  /
    Procedure created.
    SCOTT@orcl12c> -- create program, define metadata, and enable:
    SCOTT@orcl12c> BEGIN
      2    DBMS_SCHEDULER.CREATE_PROGRAM
      3       (program_name          => 'prog1',
      4        program_type          => 'stored_procedure',
      5        program_action      => 'YYYY',
      6        number_of_arguments => 1,
      7        enabled          => FALSE);
      8    DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT(
      9       program_name         => 'prog1',
    10       metadata_attribute  => 'event_message',
    11       argument_position   => 1);
    12    DBMS_SCHEDULER.ENABLE ('prog1');
    13  END;
    14  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> BEGIN
      2    -- create file watcher:
      3    DBMS_SCHEDULER.CREATE_FILE_WATCHER
      4       (file_watcher_name   => 'file_watcher1',
      5        directory_path      => 'c:\my_oracle_files',
      6        file_name          => 'f*.txt',
      7        credential_name     => 'cred',
      8        destination          => NULL,
      9        enabled          => FALSE);
    10  END;
    11  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> BEGIN
      2    -- create job:
      3    DBMS_SCHEDULER.CREATE_JOB
      4       (job_name          => 'job1',
      5        program_name          => 'prog1',
      6        queue_spec          => 'file_watcher1',
      7        auto_drop          => FALSE,
      8        enabled          => FALSE);
      9    -- set attributes:
    10    DBMS_SCHEDULER.SET_ATTRIBUTE ('job1', 'PARALLEL_INSTANCES', TRUE);
    11  END;
    12  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- enable:
    SCOTT@orcl12c> EXEC DBMS_SCHEDULER.enable ('file_watcher1, job1');
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- write file (file must not exist previously):
    SCOTT@orcl12c> CREATE OR REPLACE DIRECTORY upncommon_dir AS 'c:\my_oracle_files'
      2  /
    Directory created.
    SCOTT@orcl12c> declare
      2    filtyp utl_file.file_type;
      3  begin
      4    filtyp := utl_file.fopen ('UPNCOMMON_DIR', 'file1.txt', 'W', NULL);
      5    utl_file.put_line (filtyp, 'File has arrived ' || SYSTIMESTAMP, TRUE);
      6    utl_file.fclose (filtyp);
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- wait long enough (may take more than one minute) for job to run:
    SCOTT@orcl12c> EXEC DBMS_LOCK.SLEEP (100)
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- check for results:
    SCOTT@orcl12c> SELECT * FROM zzzz
      2  /
    WHEN
    FILE_NAME
    FILE_SIZE P
    22-OCT-13 10.12.28.309000 PM
    c:\my_oracle_files/file1.txt
            57 N
    1 row selected.
    SCOTT@orcl12c> declare
      2    filtyp utl_file.file_type;
      3  begin
      4    filtyp := utl_file.fopen ('UPNCOMMON_DIR', 'file2.txt', 'W', NULL);
      5    utl_file.put_line (filtyp, 'File has arrived ' || SYSTIMESTAMP, TRUE);
      6    utl_file.fclose (filtyp);
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- wait long enough (may take more than one minute) for job to run:
    SCOTT@orcl12c> EXEC DBMS_LOCK.SLEEP (100)
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> -- check for results:
    SCOTT@orcl12c> SELECT * FROM zzzz
      2  /
    WHEN
    FILE_NAME
    FILE_SIZE P
    22-OCT-13 10.12.28.309000 PM
    c:\my_oracle_files/file1.txt
            57 N
    22-OCT-13 10.14.08.580000 PM
    c:\my_oracle_files/file2.txt
            57 N
    2 rows selected.

  • Job not running on expected time

    Hi,
    Please see the job details
    X NUMBER;
    BEGIN
    SYS.DBMS_JOB.SUBMIT
    *( job => X*
    *,what => 'BEGIN INVS_RIM_DATA_LOAD(''01A'',''RIMADMIN'',TRUNC(SYSDATE)); END;'*
    *,next_date => to_date('15/08/2011 23:09:00','dd/mm/yyyy hh24:mi:ss')*
    *,interval => 'TRUNC(SYSDATE+1)+23.15/24'*
    *,no_parse => TRUE*
    SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
    END;
    commit;
    For taking the cold backup, db is shut down on every Friday 11:00PM and open by 02:30 PM Saturday. So job expected to run on Friday night will be running by Saturday 02:30AM. It is ok for us. But problem is job is not running on Saturday night.
    When checked on Sunday morning the user_jobs shows details as
    Last_date : 13-Aug-2011 02:30:14 AM
    Next_Date : 14-Aug-2011 11:09:00 PM
    Issue we are facing is job is not running on 13-Aug 11:09:00 PM
    Please help me to fix this issue.

    Well, it runs on the expected time (for me). This is your interval: TRUNC(SYSDATE+1)+23.15/24
    If the last job run at 13-Aug-2011 02:30:14 AM, then the next one should be:
    = TRUNC( '13-Aug-2011 02:30:14 AM' + 1 ) + 23.15/24
    = TRUNC( '14-Aug-2011 02:30:14 AM' ) + 23.15/24
    = '14-Aug-2011' + 23.15/24
    = '14-Aug-2011 11:09:00 PM'
    You can create an additional job which will work at Saturday nights. This is the easiest fix I can think.
    Regards
    Gokhan Atil

  • Since upgrading to Yosemite I can not run my airport express' without having to reset each of them every time I wish to use them. Does anyone know what the problem is?

    I am running a 7 year old MacBook Pro 15. Since upgrading to Yosemite I can not run my airport express' without having to reset each of them every time I wish to use them. I did not have this problem with Mavericks OSX. Does anyone know what the problem is and is there a fix?

    See
    What is a kernel panic,
    Technical Note TN2063: Understanding and Debugging Kernel Panics,
    Mac OS X Kernel Panic FAQ,
    Resolving Kernel Panics, and
    Tutorial: Avoiding and eliminating Kernel panics for more details.

  • Test Stand LabView adapter 8.6 run time will not run 8.5 VIs

    I’m trying to run a script I developed with a dev computer on
    a regular PC set up with a Test Stand User Gui, and run times for Test Stand
    and Labview.
    With the Test Stand Labview adapter set to 8.6.1 all of my
    ENA(Agilent Network Analyzer) calls fail for “VI Version is too early to
    convert  to the current  LabVIEW version.”  The ENA library is written in 8.5.  If I set the adapter to 8.5.1 then all of the
    VIs developed in 8.6 fail.  In addition
    it will not run any VIs that I save back to 8.5.  I installed a demo Labview development
    version (2010?) and everything ran fine with the adapter set to Development
    System.
    I am not sure what to try next to get it to run on the
    regular PC, any hints.
    Test Stand = 4.2
    LabView = 8.6
    Running in windows XP
    Solved!
    Go to Solution.

    One of the many things I tried was saving the ENA library to 8.6, but I could not get it work.
    This is the Original library I installed and was trying to Convert (8.0 upgrade agena.zip)
    http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=001CE83736F3674BE0440003BA7CCD...
    I am about to try this one. (8.2.1 Upgrade)
    http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=74D1F1D4EB5268E8E04400144FB7D2...
    I am pretty new to labview so I am not sure how to make the save to previous version workfor libraries, but I can easily do it with individual VIs.  For libraries, it creates a new directory, and puts in all of the files and then asks me about saving the lib files as something else.  This is where I think I get it wrong.  I tried it again today and got the same results.
    I greatly appreciate the Help
    Brian

  • Timer not expired while running process

    Dear All
    I'm using timer to blink the text message in 6i forms.Its working fine.
    But the problem is while running process timer not expired.
    If there is any solution to expire timer while running process, please let me know
    Thanking you

    As I understood you want to expire the timer in a specific time.
    you can call SET-TIMER with NO_REPEAT Indicates that the timer should not repeat upon expiration, but is to be used once only, until explicitly called again.
    You can call it every time that you want

  • Hi, I just bought the new i phone 5. I have plugged it into my computer a few times to run the back up and it has previously worked fine. When i try to connect it into the computer it is not recognised and will not do anything at all??

    few times to run the back up and it has previously worked fine. When i try to connect it into the computer it is not recognised and will not do anything at all??

    By calling iPod tech support while you are under warranty.  You also have 14 days to return it w/no questions asked for a replacement or your $$$ back. 

  • Hi, how to load mac without running windows (bootcamp)? The problem is this: the last time i ran the windows, but he hangs and died (can not run further  the logo). now i can not load not windows, not maс! how to be, what to do???

    The problem is this: the last time i ran the windows, but he hangs and died (can not run further  the logo). now i can not load not windows, not maс! how to be, what to do???

    can any body help me, plz!!

  • Time Machine "freezes" and I am NOT running anti-virus software

    I am incredibly frustrasted and disappointed as a first-time Apple user (brand new iMac (Intel-based) with an external LaCie 500 GB external hard disk). The problem is Time Machine. It backs up on schedule, but when I enter Time Machine, I cannot navigate at all. The background screen (outer space) moves, the cursor moves, but I cannot click on anything. I have to "force quit". So I guess I have things backed up, but can't do anything with them.
    I am NOT running antivirus software. I had Intego loaded on the computer, but removed it completely after reading on Apple blogs that this could interfere with Time Machine. I have reformatted the external hard disk. Still, Time Machine freezes. Apple has put out a couple of patches, I understand, but that was months ago and all of my software is up to date.
    I have called Apple support TWICE and they act as if I am from the moon -- how dare I question that the Time Machine does not work properly?
    Does anyone out there know how to fix this? I am ready to return this computer to the Apple store, which cheerfully sold me on the idea of an external hard disk as a back-up.

    Hello Zurichmike (lovely country):
    Welcome to Apple discussions.
    There are several things you could try. Easy ones first:
    Erase and reformat your external HD.
    Run repair disk from your software install DVD (on your internal HD).
    Go to Macintosh HD>library>preferences. Trash the TM preference file (com.apple.timemachine.plist) and restart. The TM preferences will need to be changed as they are now default values.
    Barry

Maybe you are looking for