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

Cursor sync implementation causes deadlock on win32 Kestrel-G

XMLWordPrintable

    • 2d
    • 1.3
    • generic, x86
    • windows_95, windows_nt
    • Verified

      The implementation of "cursor sync" causes deadlock on win32.
      Run the following sample, try to move one frame to cover part of
      another frame and keep using mouse to change position slightly,
      the VM will hang up soon. Seems to me the calling of _un_shield_cursor()
      in awt_Graphics.cpp is the one of reasons, try using PostMessage() in
      both _shield_cursor() and _un_shield_cursor() should solve the problem...

      import java.applet.*;
      import java.awt.*;
      import java.awt.event.*;

      public class deadlock extends Panel implements KeyListener {

        public static void main(String argv[]) {
          Frame frame1 = new Frame("lightweight1");
          Frame frame2 = new Frame("lightweight2");

          deadlock dl1 = new deadlock("lightweight1");
          //dl1.setSize(200,100);
          frame1.add("Center", dl1);
          frame1.setSize(200, 100);

          deadlock dl2 = new deadlock("lightweight2");
          //dl2.setSize(200,100);
          frame2.add("Center", dl2);
          frame2.setSize(200, 100);


          WindowListener listener = new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
      e.getWindow().dispose();
      System.exit(0);
            };
          };


          frame1.addWindowListener(listener);
          frame1.validate();
          frame1.setVisible(true);

          frame2.addWindowListener(listener);
          frame2.validate();
          frame2.setVisible(true);


        }


          String name;
          char key;

          public deadlock(String name) {
              super();
              this.name = name;
      setSize(400, 60);
      setBackground(Color.cyan);
      setForeground(Color.black);
      setVisible(true);
      setEnabled(true);
      addKeyListener(this);
          }

          public void paint(Graphics g) {
              g.setColor(getBackground());
      Dimension size = getSize();
      g.fillRect(0, 0, size.width, size.height);
      g.setColor(getForeground());
              ((Graphics2D)g).drawString(name + "==>" + key, 10, 20);

          }

          public void keyTyped(KeyEvent e){
                key = e.getKeyChar();
                paint(getGraphics());
          }
          public void keyPressed(KeyEvent e){}
          public void keyReleased(KeyEvent e){}

      }

            dfeldsunw Dmitry Feld (Inactive)
            sherman Xueming Shen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: