Skip to content

Commit d2b119f

Browse files
committed
GH-470 run graph refresh code outside of AWT
1 parent 05c590d commit d2b119f

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

visualvm/hostviews/src/org/graalvm/visualvm/host/views/overview/HostOverviewView.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@
3838
import org.graalvm.visualvm.core.ui.components.NotSupportedDisplayer;
3939
import org.graalvm.visualvm.uisupport.HTMLTextArea;
4040
import java.awt.BorderLayout;
41-
import java.awt.event.ActionEvent;
42-
import java.awt.event.ActionListener;
4341
import java.text.NumberFormat;
42+
import java.util.Timer;
43+
import java.util.TimerTask;
4444
import javax.swing.BorderFactory;
4545
import javax.swing.ImageIcon;
4646
import javax.swing.JPanel;
47-
import javax.swing.SwingUtilities;
48-
import javax.swing.Timer;
4947
import org.openide.util.ImageUtilities;
5048
import org.openide.util.NbBundle;
5149

@@ -70,11 +68,11 @@ protected void willBeAdded() {
7068
}
7169

7270
protected void removed() {
73-
timer.stop();
71+
timer.cancel();
7472
}
7573

7674
public void dataRemoved(Host dataSource) {
77-
timer.stop();
75+
timer.cancel();
7876
}
7977

8078

@@ -100,20 +98,15 @@ protected DataViewComponent createComponent() {
10098
final SwapMemoryViewSupport swapMemoryViewSupport = new SwapMemoryViewSupport(chartCache);
10199
dvc.addDetailsView(swapMemoryViewSupport.getDetailsView(), DataViewComponent.TOP_RIGHT);
102100

103-
timer = new Timer(2000, new ActionListener() {
104-
public void actionPerformed(ActionEvent e) {
101+
timer = new Timer();
102+
timer.schedule(new TimerTask() {
103+
public void run() {
105104
final long time = System.currentTimeMillis();
106-
SwingUtilities.invokeLater(new Runnable() {
107-
public void run() {
108-
cpuLoadViewSupport.refresh(hostOverview, time);
109-
physicalMemoryViewSupport.refresh(hostOverview, time);
110-
swapMemoryViewSupport.refresh(hostOverview, time);
111-
}
112-
});
105+
cpuLoadViewSupport.refresh(hostOverview, time);
106+
physicalMemoryViewSupport.refresh(hostOverview, time);
107+
swapMemoryViewSupport.refresh(hostOverview, time);
113108
}
114-
});
115-
timer.setInitialDelay(800);
116-
timer.start();
109+
}, 800, 2000);
117110
((Host)getDataSource()).notifyWhenRemoved(this);
118111

119112
return dvc;

0 commit comments

Comments
 (0)