<AWT Dev> Endless loop in EventDispatchThread - proposed solution

Artem Ananiev artem.ananiev at oracle.com
Wed Aug 24 08:17:12 PDT 2011

Hi, Clemens,

the minimal patch looks fine.

The full patch also looks OK. Yesterday I thought in exactly the same 
direction and here is my observation. EDT.pumpEventsForFilters(id) can 
return the "false" value only if the thread is interrupted or stopped 
(ThreadDeath is caught). Therefore when the pumpEvents() call in 
EDT.run() exits, "shutdown" is always true. That's why I wrote about 
detaching the event dispatch thread unconditionally in my previous email.

Did I miss anything?



On 8/24/2011 2:05 PM, Clemens Eisserer wrote:
> Hi,
> 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