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

paint() method doc needs updating regarding AWT tree lock

XMLWordPrintable

    • generic
    • generic



      Name: md23716 Date: 08/23/2001

      A paint() method invocation of an awt Component from a synchronized block can result in a deadlock.

      The deadlock occurs between the AWT-EventQueue-0 and the user thread(in this case, ProxyEventQueue). The AWT-EventQueue-0 acquires the class instance and waits for the AWT Tree lock. The user thread acquires the AWT tree lock (may be through a validate() call) and waits for the lock on the class instance.

      The AWT tree lock was introduced in 1.3 and which was not present in 1.2.

      Source code that demonstrates the problem:
      synchronized void clearScreen(){
             changeCursor(OFF,false);
             offscreen.setColor(color_bg);
             offscreen.fillRect(0, 0, screenWidth, screenHeight);
             changeCursor(ON,false);
             if (dragBox)
               drawDragBox();
             repaint();
          }

      Suggested solution is to change the documentation for the paint() method regarding the AWT tree lock, if the method is being called from inside a synchronized block.

      ======================================================================

            art Artem Ananiev (Inactive)
            mdevereuorcl Michelle Devereux (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: