<AWT Dev> Endless loop in EventDispatchThread - proposed solution

Clemens Eisserer linuxhippy at gmail.com
Tue Aug 30 03:04:19 PDT 2011

Hi Artem,

> I'm fine with EventDispatchThread.java changes from the full version. Are
> the pushPopLock.**isHeldByCurrentThread() checks required, given that
> EDT.interrupt() is now respected?

The checks avoid hanging in case Thread.stop() has been called, without
Thread.interrupt() before, as you stated:

What if somebody calls EDT.stop() directly, without preceding interrupt()? I
> understand this is not a typical scenario, and we probably shouldn't support
> it, but we should at least not hang.

I prepared another patch, which does not require those checks to avoid
hanging, however it will print out an IllegalMonitorStateException in the
case stop() has been called, without interrupt() before:

The patch with the checks in is located at:

 Once approved, the fix should go to JDK8 workspace first. Then it will be
> backported to JDK7u.

Perfect :)

   Caused by: java.lang.RuntimeException: Die, AWT-Event Queue thread!
>         at HostileCrasher.<clinit>(LoopRobustness.java:157)
>         ... 23 more
>    Exception in thread "main" java.lang.RuntimeException: Test FAILED:
>    second thread hasn't notified MainThread
>         at LoopRobustness.main(LoopRobustness.java:70)

Hmm... That's odd. The test passes on my Windows desktop. The first stack
> trace is printed to the console, but it's expected as e.printStackTrace() is
> called from the test. However, the second exception thrown from
> LoopRobustness.java:70 looks the real problem.

Its basically the same problem, there is a fixed timeout (5s) but
sun.awt.SunToolkit.realSync waits for 10s and then times out.
If I increase the timeout to 60s I get the same Exception as with the other

> sun.awt.SunToolkit$OperationTimedOut: 10932
>     at sun.awt.X11.XToolkit.syncNativeQueue(XToolkit.java:2443)
>     at sun.awt.SunToolkit.realSync(SunToolkit.java:1580)
>     at sun.awt.SunToolkit.realSync(SunToolkit.java:1512)
>     at test.java.awt.regtesthelpers.Util.waitForIdle(Util.java:184)
>     at Impl.run(LoopRobustness.java:114)
>     at java.lang.Thread.run(Thread.java:722)

Thanks, Clemens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20110830/3701620e/attachment.html 

More information about the awt-dev mailing list