<AWT Dev> Endless loop in EventDispatchThread - proposed solution

Roman Kennke roman at kennke.org
Wed Aug 24 03:07:59 PDT 2011

Hi Clemens,

Would be nice to live in a world without Thread.stop(). Unfortunately,
this is used by the Applet plugin to terminate applets that don't
respond to anything else, so we might need to keep it around (at least
honor it when it happens).


> Please find the proposed fix at:
> http://cr.openjdk.java.net/~ceisserer/7081670/
> The "minimal" patch just tries to restore the behaviour when monitors
> were used, trying to be low-risk.
> The "full" patch does no longer rely on async exeptions (but still
> honors them if they happen), and calls detachQueue unconditionally on
> shutdown (but still takes care of pending events of only
> stopDispatch() has been called).
> I didn't change AppContext.dispose(), as I think calling Thread.stop()
> may be still benefitial to kill application-specific threads which
> don't honor interrupt().
> I took the liberty to do a small amount of low-risk refactoring:
> - Replaced Vector with ArrayList, as it is only accessed after
> acquiring its monitor
> - Replaced event-queue id gerenation code with AtomicInteger
> - Made waitForID volatile, as it is accessed by multiple threads.
> Thanks, Clemens

More information about the awt-dev mailing list