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

race condition that can occur when a modal dialog box is closed.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1
    • client-libs
    • sparc
    • solaris_2.5.1

      There is a race condition that can occur when a modal dialog box is closed.

      In src/share/java/java/awt/Dialog.java, in the show() method,
      a new event dispatching thread is created for the modal dialog
      box. The peer's show method is called, which blocks until
      the dialog box is hidden. At this point, stopDispatching() is
      called against the Dialog box's own dispatching thread, and
      then control returns to the caller. If the caller of
      Dialog.show() had been an event handler, then control goes
      straight back to the original dispatching thread. The problem
      with this is that the Dialog's thread has actually not
      finished yet, so there is a potential race condition here.

      One situation in which this causes a problem is a test case
      in which a modal dialog box is opened from the event handler of
      a button in a frame. This event handler calls the dialog's
      show method and then disposes the frame. The idea is that when
      the dialog box is closed, the frame underneath it is also
      closed.

      The dialog box is closed by a button method which disposes the
      dialog. Now - a dispose starts by issuing a hide, which will
      cause the modal dialog peer's show loop to exit - but, the
      dispose is still happening. Control is returned to the caller
      at this point, and the caller disposes the fame. Now, because
      the dialog is a child of the frame, disposing the frame will
      also dispose the dialog. Therefore, the dialog is disposed by
      two threads at the same time.

            rkhansunw Robi Khan (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: