--- old/src/share/classes/sun/awt/SunToolkit.java 2018-09-28 08:14:26.744537019 -0700 +++ new/src/share/classes/sun/awt/SunToolkit.java 2018-09-28 08:14:26.554518918 -0700 @@ -1620,9 +1620,9 @@ */ protected abstract boolean syncNativeQueue(final long timeout); - private boolean eventDispatched = false; - private boolean queueEmpty = false; - private final Object waitLock = "Wait Lock"; + private boolean eventDispatched; + private boolean queueEmpty; + private final Object waitLock = new Object(); private boolean isEQEmpty() { EventQueue queue = getSystemEventQueueImpl(); @@ -1639,10 +1639,11 @@ @SuppressWarnings("serial") protected final boolean waitForIdle(final long timeout) { flushPendingEvents(); - boolean queueWasEmpty = isEQEmpty(); - queueEmpty = false; - eventDispatched = false; - synchronized(waitLock) { + final boolean queueWasEmpty; + synchronized (waitLock) { + queueWasEmpty = isEQEmpty(); + queueEmpty = false; + eventDispatched = false; postEvent(AppContext.getAppContext(), new PeerEvent(getSystemEventQueueImpl(), null, PeerEvent.LOW_PRIORITY_EVENT) { public void dispatch() {