Skip to content

Commit e34a4b6

Browse files
committed
Fixed synchronization in computing children
1 parent 05c5bed commit e34a4b6

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/model/HeapViewerNode.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,17 @@ protected HeapViewerNode[] doInBackground() throws Exception {
189189
return ret;
190190
}
191191
protected void done() {
192-
if (children != null) try {
193-
HeapViewerNode[] newChildren = get();
194-
// newChildren may be null, for example if the worker thread has been interrupted
195-
if (newChildren != null) {
196-
setChildren(newChildren);
197-
root.updateChildren(HeapViewerNode.this);
192+
synchronized (HeapViewerNode.this) {
193+
if (currentWorker == null) try {
194+
HeapViewerNode[] newChildren = get();
195+
// newChildren may be null, for example if the worker thread has been interrupted
196+
if (newChildren != null) {
197+
setChildren(newChildren);
198+
root.updateChildren(HeapViewerNode.this);
199+
}
200+
} catch (Exception ex) {
201+
Exceptions.printStackTrace(ex);
198202
}
199-
} catch (Exception ex) {
200-
Exceptions.printStackTrace(ex);
201203
}
202204
}
203205
};

0 commit comments

Comments
 (0)