提交 f4327351 编写于 作者: A anashaty

8078606: Deadlock in awt clipboard

Reviewed-by: azvegint, bae
上级 d843740b
......@@ -156,19 +156,29 @@ public final class XClipboard extends SunClipboard implements OwnershipListener
isSelectionNotifyProcessed = true;
boolean mustSchedule = false;
synchronized (XClipboard.classLock) {
if (targetsAtom2Clipboard == null) {
targetsAtom2Clipboard = new HashMap<Long, XClipboard>(2);
XToolkit.awtLock();
try {
synchronized (XClipboard.classLock) {
try {
Thread.sleep(70);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
if (targetsAtom2Clipboard == null) {
targetsAtom2Clipboard = new HashMap<Long, XClipboard>(2);
}
mustSchedule = targetsAtom2Clipboard.isEmpty();
targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this);
if (mustSchedule) {
XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(),
new SelectionNotifyHandler());
}
}
mustSchedule = targetsAtom2Clipboard.isEmpty();
targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this);
if (mustSchedule) {
XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(),
new SelectionNotifyHandler());
XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval());
}
}
if (mustSchedule) {
XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval());
} finally {
XToolkit.awtUnlock();
}
}
......
......@@ -31,18 +31,22 @@ package sun.awt.X11;
* common logical ancestor
*/
class XRootWindow extends XBaseWindow {
private static XRootWindow xawtRootWindow = null;
static XRootWindow getInstance() {
XToolkit.awtLock();
try {
if (xawtRootWindow == null) {
private static class LazyHolder {
private static final XRootWindow xawtRootWindow;
static {
XToolkit.awtLock();
try {
xawtRootWindow = new XRootWindow();
xawtRootWindow.init(xawtRootWindow.getDelayedParams().delete(DELAYED));
} finally {
XToolkit.awtUnlock();
}
return xawtRootWindow;
} finally {
XToolkit.awtUnlock();
}
}
static XRootWindow getInstance() {
return LazyHolder.xawtRootWindow;
}
private XRootWindow() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册