Skip to content

Commit 8af6174

Browse files
committed
Do not resolve threadCount/daemonThreadCount asynchronously, update together with new thread data
1 parent 9613ddd commit 8af6174

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

visualvm/applicationviews/src/org/graalvm/visualvm/application/views/threads/ApplicationThreadsView.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,23 +260,23 @@ public void actionPerformed(ActionEvent e) {
260260
private void updateThreadsCounts(final VisualVMThreadsDataManager threadsManager) {
261261

262262
final int[] threads = new int[2];
263-
264-
getWorker().post(new Runnable() {
265-
public void run() {
266-
try {
263+
// TODO: needs a worker thread to read threadCount/daemonThreadCount?
264+
// getWorker().post(new Runnable() {
265+
// public void run() {
266+
// try {
267267
threads[0] = threadsManager.getThreadCount();
268268
threads[1] = threadsManager.getDaemonThreadCount();
269-
} catch (Exception ex) {
270-
threads[0] = 0;
271-
threads[1] = 0;
272-
}
269+
// } catch (Exception ex) {
270+
// threads[0] = 0;
271+
// threads[1] = 0;
272+
// }
273273
SwingUtilities.invokeLater(new Runnable() {
274274
public void run() {
275275
updateThreadsCounts(threads[0], threads[1]);
276276
}
277277
});
278-
}
279-
});
278+
// }
279+
// });
280280
}
281281

282282
private void setAlertText(String alert) {

visualvm/applicationviews/src/org/graalvm/visualvm/application/views/threads/ThreadMXBeanDataManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ class ThreadMXBeanDataManager extends VisualVMThreadsDataManager {
5656
private DeadlockDetector deadlockDetector;
5757
private PropertyChangeSupport changeSupport;
5858
private long[] deadlockThreadIds;
59+
60+
private int threadCount, daemonThreadCount;
61+
5962

6063
ThreadMXBeanDataManager(ThreadMXBean tb) {
6164
threadBean = tb;
@@ -90,6 +93,8 @@ void refreshThreadsSync() {
9093
try {
9194
ThreadMonitoredDataResponse resp = new ThreadMonitoredDataResponse();
9295
resp.fillInThreadData();
96+
threadCount = threadBean.getThreadCount();
97+
daemonThreadCount = threadBean.getDaemonThreadCount();
9398
final MonitoredData monitoredData = MonitoredData.getMonitoredData(resp);
9499
SwingUtilities.invokeLater(new Runnable() {
95100

@@ -104,11 +109,11 @@ public void run() {
104109
}
105110

106111
int getDaemonThreadCount() {
107-
return threadBean.getDaemonThreadCount();
112+
return daemonThreadCount;
108113
}
109114

110115
int getThreadCount() {
111-
return threadBean.getThreadCount();
116+
return threadCount;
112117
}
113118

114119
void addPropertyChangeListener(PropertyChangeListener l) {

0 commit comments

Comments
 (0)