-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1
-
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.
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.
- duplicates
-
JDK-4122683 hiding modal Dialog on NT can deadlock, freezing GUI
- Closed