On Aug 29, 2014, at 23:39, Michael Hall <mik3h...@gmail.com> wrote: > On Aug 29, 2014, at 7:45 AM, Hendrik Schreiber <h...@tagtraum.com> wrote: > >> public void exit() { >> if (!isOwned()) { >> throw new IllegalMonitorStateException(); >> } >> LWCToolkit.stopAWTRunLoop(awtRunLoopMediator); >> awtRunLoopMediator = 0; >> } > > What does isOwned() do?
It's defined in the superclass, Mutex. > Doesn't it ensure that clearing the loop mediator is only done by the owning > thread? If some other thread successfully runs through exit doesn't it mean > this is not working correctly? > [...] > Wouldn't it be simpler and safer to fix it in the JNI? > if (mediatorObject) CFRelease(mediatorObject); That's certainly also possible, but it also does not solve the issue completely. The underlying problem is that exit() shouldn't be called more than once in the first place. My suggestion for improving the sun.lwawt.macosx.CToolkitThreadBlockedHandler code were only aimed at programmatically enforcing the implicit contract. It does not solve the problem that causes the issue. I have created a test case and tried to explain what the problem is in http://mail.openjdk.java.net/pipermail/awt-dev/2014-September/008425.html hoping that AWT folks provide some input. AWT, because the class that calls exit() twice is a class shared between all platforms. It would be shortsighted to try to "fix" this only for OS X. -hendrik