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

JVM crashes with c0000005 code (access violation)

XMLWordPrintable



      Name: krT82822 Date: 05/17/99


      After some amount of time the JVM crashes with an access violation (c0000005)
      when running my code. My programm is a realy simple example that uses
      swing-JTextField (source-code attached).

      The crash reproduces itself each time it runs, it crashes sometimes after 30
      minutes, sometimes after a few hours. With the hotspot engine, it crashes
      after 5 or 10 minutes!

      Here is my source-code, please try it!

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.border.*;

      class JavaTest extends JFrame
      {
        public JavaTest()
        {
          setTitle(
            "JavaTest");
          setSize(
            1000, 400);
          addWindowListener(new WindowAdapter()
             { public void windowClosing(WindowEvent e)
                { System.exit(0);
                }
             } );

          JPanel loPanel1
            = new JPanel();
          loPanel1.setLayout(
            new GridLayout(5,5,5,5));
          
          inTexts
            = new JTextField[25];
          inThreads
            = new CounterThread[25];
          
          for (int loIdx=0;loIdx<inTexts.length;loIdx++)
          {
            inTexts[loIdx]
              = new JTextField();

            inTexts[loIdx].setEditable(
              false);
            inTexts[loIdx].setHorizontalAlignment(
              JTextField.CENTER);
              
            loPanel1.add(
              inTexts[loIdx]);
        
            inThreads[loIdx]
              = new CounterThread();
            inThreads[loIdx].setAttributes(
              this,inTexts[loIdx],150+loIdx*5);
            inThreads[loIdx].start(
              );
            //inThreads[loIdx].setPriority(
              //Thread.MAX_PRIORITY-2);
          }
          
          getContentPane().add(loPanel1);
        }
       
        public static void main(String[] args)
        {
          JavaTest loFrame
            = new JavaTest();
          loFrame.show(
            );
        }
        
        private JTextField[] inTexts;
        private CounterThread[] inThreads;
      }


      class CounterThread extends Thread
      {
        public CounterThread()
        {
          super(
            );
          inCounter
            = MIN;
        }
        
        public void setAttributes(JavaTest paTest,JTextField paComp,int paDelay)
        {
          inTest
            = paTest;
          inComp
            = paComp;
          inDelay
            = paDelay;
        }

        
        public void run()
        {
          Thread myThread
            = Thread.currentThread();
          try
          {
            sleep(
              3000);
          }
          catch (InterruptedException e)
          {
            // the VM doesn't want us to sleep anymore,
            // so get back to work
          }
          while (this == myThread)
          {
            if ((inUp == true) && (inCounter < MAX))
            {
              inCounter
                +=1;
            }
            else if ((inUp == false) && (inCounter > MIN))
            {
              inCounter
                -=1;
            }
            else if (inCounter == MAX)
            {
              inUp
                = false;
            }
            else
            {
              inUp
                = true;
            }

            inComp.setText(
              "counter: " + inCounter);

            try
            {
              sleep(
                inDelay);
            }
            catch (InterruptedException e)
            {
              // the VM doesn't want us to sleep anymore,
              // so get back to work
            }
          }
        }
        
        private JTextField inComp;
        private JavaTest inTest;
        private int inDelay;
        private int inCounter;
        private boolean inUp
          = true;
        
        private final int MAX
          = 50;
        private final int MIN
          = -50;
      }
      (Review ID: 83133)
      ======================================================================

            Unassigned Unassigned
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: