Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6792511

main exists before javax.swing.Timer's start() can start

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6
    • client-libs
    • x86
    • windows_vista

      FULL PRODUCT VERSION :
      java version "1.6.0_07"
      Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
      Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.0.6001]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Nothing in particular: dual core,

      A DESCRIPTION OF THE PROBLEM :
      In a little demo program, main creates a javax.swing.Timer object. After starting it with a start(), the main exits. The Timer doesn't start, no actionPerformed occurs.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      create an javax.swing.Timer object, with anonymous inner class actionPreformed.
      Execute the object's start() method.
      Exit the main.
      (see supplied code)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expect the timer to start running and continue to run.
      ACTUAL -
      Main exits, timer does not execute.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no output

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.event.*;
      // Shows bug in swing Timer, by Michael Floeser.
      public class TimerSwingTest
      {
      private static int swingCount = 0;
      public static void main(String [] args)
      { // 1000 time here, <=999 it keeps going with Thread.sleep, otherwise exits.
      javax.swing.Timer swingTime = new javax.swing.Timer( 1000, new ActionListener() {
      public void actionPerformed(ActionEvent ae)
      {
      System.out.println("Swing time count = " + ++swingCount );
      }
      } );

      swingTime.start();

      // sleep below <1000, (eg: 500), or removed, thread doesn't run
      // =1000-IllegalStateException
      // >1000-(eg: 2000) runs, but frequently exists ~1 minute or less
      // try{ Thread.sleep(2000); }
      // catch(Exception e){System.out.println("Sleep exception");}
      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Adding the Thread.sleep(2000) has it run, but frequently exists after about a minute. Sometimes it exists between 20 and 80 seconds, sometimes it goes longer.

            art Artem Ananiev (Inactive)
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: