jdk/src/share/classes/sun/tools/jconsole/ThreadTab.java
author michaelm
Thu, 24 Oct 2013 20:39:21 +0100
changeset 22339 e91bfaf4360d
parent 19582 1cab3f8c48c7
child 22094 1c154d8a9a96
permissions -rw-r--r--
8011786: Better applet networking Reviewed-by: alanb, chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 12851
diff changeset
     2
 * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.tools.jconsole;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.management.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.reflect.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.swing.border.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.swing.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
    38
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.concurrent.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import static sun.tools.jconsole.Utilities.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
@SuppressWarnings("serial")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
class ThreadTab extends Tab implements ActionListener, DocumentListener, ListSelectionListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    PlotterPanel threadMeter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    TimeComboBox timeComboBox;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    JTabbedPane threadListTabbedPane;
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
    51
    DefaultListModel<Long> listModel;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    JTextField filterTF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    JLabel messageLabel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    JSplitPane threadsSplitPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    HashMap<Long, String> nameCache = new HashMap<Long, String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private ThreadOverviewPanel overviewPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private boolean plotterListening = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private static final String threadCountKey   = "threadCount";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private static final String peakKey          = "peak";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static final Color  threadCountColor = Plotter.defaultColor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private static final Color  peakColor        = Color.red;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private static final Border thinEmptyBorder  = new EmptyBorder(2, 2, 2, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private static final String infoLabelFormat = "ThreadTab.infoLabelFormat";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
      Hierarchy of panels and layouts for this tab:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        ThreadTab (BorderLayout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            North:  topPanel (BorderLayout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                        Center: controlPanel (FlowLayout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                                    timeComboBox
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            Center: plotterPanel (BorderLayout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                        Center: plotter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    public static String getTabName() {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
    90
        return Messages.THREADS;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public ThreadTab(VMPanel vmPanel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        super(vmPanel, getTabName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        setLayout(new BorderLayout(0, 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        setBorder(new EmptyBorder(4, 4, 3, 4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        JPanel topPanel     = new JPanel(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        JPanel plotterPanel = new JPanel(new VariableGridLayout(0, 1, 4, 4, true, true));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        add(topPanel, BorderLayout.NORTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        add(plotterPanel,  BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 5));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        topPanel.add(controlPanel, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   108
        threadMeter = new PlotterPanel(Messages.NUMBER_OF_THREADS,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                                       Plotter.Unit.NONE, true);
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   110
        threadMeter.plotter.createSequence(threadCountKey, Messages.LIVE_THREADS,  threadCountColor, true);
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   111
        threadMeter.plotter.createSequence(peakKey,        Messages.PEAK,         peakColor,        true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        setAccessibleName(threadMeter.plotter,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   113
                          Messages.THREAD_TAB_THREAD_PLOTTER_ACCESSIBLE_NAME);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        plotterPanel.add(threadMeter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        timeComboBox = new TimeComboBox(threadMeter.plotter);
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   118
        controlPanel.add(new LabeledComponent(Messages.TIME_RANGE_COLON,
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   119
                                              Resources.getMnemonicInt(Messages.TIME_RANGE_COLON),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                                              timeComboBox));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   122
        listModel = new DefaultListModel<Long>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        JTextArea textArea = new JTextArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        textArea.setBorder(thinEmptyBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        textArea.setEditable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        setAccessibleName(textArea,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   128
                          Messages.THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME);
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   129
        ThreadJList list = new ThreadJList(listModel, textArea);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        Dimension di = new Dimension(super.getPreferredSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        di.width = Math.min(di.width, 200);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        JScrollPane threadlistSP = new JScrollPane(list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        threadlistSP.setPreferredSize(di);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        threadlistSP.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        JScrollPane textAreaSP = new JScrollPane(textArea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        textAreaSP.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        threadListTabbedPane = new JTabbedPane(JTabbedPane.TOP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        threadsSplitPane  = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                                           threadlistSP, textAreaSP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        threadsSplitPane.setOneTouchExpandable(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        threadsSplitPane.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        JPanel firstTabPanel = new JPanel(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        firstTabPanel.setOpaque(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        JPanel firstTabToolPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        firstTabToolPanel.setOpaque(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        filterTF = new PromptingTextField("Filter", 20);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        filterTF.getDocument().addDocumentListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        firstTabToolPanel.add(filterTF);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        JSeparator separator = new JSeparator(JSeparator.VERTICAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        separator.setPreferredSize(new Dimension(separator.getPreferredSize().width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                                                 filterTF.getPreferredSize().height));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        firstTabToolPanel.add(separator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   162
        JButton detectDeadlockButton = new JButton(Messages.DETECT_DEADLOCK);
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   163
        detectDeadlockButton.setMnemonic(Resources.getMnemonicInt(Messages.DETECT_DEADLOCK));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        detectDeadlockButton.setActionCommand("detectDeadlock");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        detectDeadlockButton.addActionListener(this);
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   166
        detectDeadlockButton.setToolTipText(Messages.DETECT_DEADLOCK_TOOLTIP);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        firstTabToolPanel.add(detectDeadlockButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        messageLabel = new JLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        firstTabToolPanel.add(messageLabel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        firstTabPanel.add(threadsSplitPane, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        firstTabPanel.add(firstTabToolPanel, BorderLayout.SOUTH);
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   174
        threadListTabbedPane.addTab(Messages.THREADS, firstTabPanel);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        plotterPanel.add(threadListTabbedPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    private long oldThreads[] = new long[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public SwingWorker<?, ?> newSwingWorker() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        final ProxyClient proxyClient = vmPanel.getProxyClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if (!plotterListening) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            proxyClient.addWeakPropertyChangeListener(threadMeter.plotter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            plotterListening = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        return new SwingWorker<Boolean, Object>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            private int tlCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            private int tpCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            private long ttCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            private long[] threads;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            private long timeStamp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            public Boolean doInBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    ThreadMXBean threadMBean = proxyClient.getThreadMXBean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                    tlCount = threadMBean.getThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    tpCount = threadMBean.getPeakThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                    if (overviewPanel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                        ttCount = threadMBean.getTotalStartedThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                        ttCount = 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                    threads = threadMBean.getAllThreadIds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                    for (long newThread : threads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                        if (nameCache.get(newThread) == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                            ThreadInfo ti = threadMBean.getThreadInfo(newThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                            if (ti != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                String name = ti.getThreadName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                if (name != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                                    nameCache.put(newThread, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    timeStamp = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                } catch (UndeclaredThrowableException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            protected void done() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                    if (!get()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                } catch (InterruptedException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                } catch (ExecutionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                    if (JConsole.isDebug()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                        ex.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                threadMeter.plotter.addValues(timeStamp, tlCount, tpCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                threadMeter.setValueLabel(tlCount+"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                if (overviewPanel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                    overviewPanel.updateThreadsInfo(tlCount, tpCount, ttCount, timeStamp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                String filter = filterTF.getText().toLowerCase(Locale.ENGLISH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                boolean doFilter = (filter.length() > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                ArrayList<Long> l = new ArrayList<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                for (long t : threads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                    l.add(t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                Iterator<Long> iterator = l.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                while (iterator.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                    long newThread = iterator.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                    String name = nameCache.get(newThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                    if (doFilter && name != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                        name.toLowerCase(Locale.ENGLISH).indexOf(filter) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                        iterator.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                long[] newThreads = threads;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                if (l.size() < threads.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                    newThreads = new long[l.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                    for (int i = 0; i < newThreads.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                        newThreads[i] = l.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                for (long oldThread : oldThreads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                    boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                    for (long newThread : newThreads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                        if (newThread == oldThread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                            found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                    if (!found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                        listModel.removeElement(oldThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                        if (!doFilter) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                            nameCache.remove(oldThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                // Threads are in reverse chronological order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                for (int i = newThreads.length - 1; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                    long newThread = newThreads[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                    boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                    for (long oldThread : oldThreads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                        if (newThread == oldThread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                            found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                    if (!found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                        listModel.addElement(newThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                oldThreads = newThreads;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    long lastSelected = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    public void valueChanged(ListSelectionEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        ThreadJList list = (ThreadJList)ev.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        final JTextArea textArea = list.textArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        Long selected = (Long)list.getSelectedValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        if (selected == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            if (lastSelected != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                selected = lastSelected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            lastSelected = selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        textArea.setText("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        if (selected != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            final long threadID = selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            workerAdd(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                    ProxyClient proxyClient = vmPanel.getProxyClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                    StringBuilder sb = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                        ThreadMXBean threadMBean = proxyClient.getThreadMXBean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                        ThreadInfo ti = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                        MonitorInfo[] monitors = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                        if (proxyClient.isLockUsageSupported() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                              threadMBean.isObjectMonitorUsageSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                            // VMs that support the monitor usage monitoring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                            ThreadInfo[] infos = threadMBean.dumpAllThreads(true, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                            for (ThreadInfo info : infos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                                if (info.getThreadId() == threadID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                                    ti = info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                                    monitors = info.getLockedMonitors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                            // VM doesn't support monitor usage monitoring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                            ti = threadMBean.getThreadInfo(threadID, Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                        if (ti != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                            if (ti.getLockName() == null) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   353
                                sb.append(Resources.format(Messages.NAME_STATE,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                                              ti.getThreadName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                                              ti.getThreadState().toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                            } else if (ti.getLockOwnerName() == null) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   357
                                sb.append(Resources.format(Messages.NAME_STATE_LOCK_NAME,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                                              ti.getThreadName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                                              ti.getThreadState().toString(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                                              ti.getLockName()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                            } else {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   362
                                sb.append(Resources.format(Messages.NAME_STATE_LOCK_NAME_LOCK_OWNER,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                                              ti.getThreadName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                                              ti.getThreadState().toString(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                                              ti.getLockName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                                              ti.getLockOwnerName()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                            }
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   368
                            sb.append(Resources.format(Messages.BLOCKED_COUNT_WAITED_COUNT,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                                              ti.getBlockedCount(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                                              ti.getWaitedCount()));
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   371
                            sb.append(Messages.STACK_TRACE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                            int index = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                            for (StackTraceElement e : ti.getStackTrace()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                                sb.append(e.toString()+"\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                                if (monitors != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                                    for (MonitorInfo mi : monitors) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                                        if (mi.getLockedStackDepth() == index) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   378
                                            sb.append(Resources.format(Messages.MONITOR_LOCKED, mi.toString()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                                index++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                    } catch (IOException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                        // Ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                    } catch (UndeclaredThrowableException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                        proxyClient.markAsDead();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                    final String text = sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                    SwingUtilities.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                            textArea.setText(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                            textArea.setCaretPosition(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    private void doUpdate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        workerAdd(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                update();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    private void detectDeadlock() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        workerAdd(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                    final Long[][] deadlockedThreads = getDeadlockedThreadIds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                    if (deadlockedThreads == null || deadlockedThreads.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                        // Display message for 30 seconds. Do it on a separate thread so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                        // the sleep won't hold up the worker queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                        // This will be replaced later by separate statusbar logic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                        new Thread() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                                    SwingUtilities.invokeAndWait(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                                        public void run() {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   426
                                            String msg = Messages.NO_DEADLOCK_DETECTED;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                                            messageLabel.setText(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                                            threadListTabbedPane.revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                                    sleep(30 * 1000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                                } catch (InterruptedException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                                    // Ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                                } catch (InvocationTargetException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                                    // Ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                                SwingUtilities.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                                        messageLabel.setText("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                        }.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                    SwingUtilities.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                            // Remove old deadlock tabs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                            while (threadListTabbedPane.getTabCount() > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                                threadListTabbedPane.removeTabAt(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                            if (deadlockedThreads != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                for (int i = 0; i < deadlockedThreads.length; i++) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   456
                                    DefaultListModel<Long> listModel = new DefaultListModel<Long>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                                    JTextArea textArea = new JTextArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                                    textArea.setBorder(thinEmptyBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                                    textArea.setEditable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                                    setAccessibleName(textArea,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   461
                                                      Messages.THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME);
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   462
                                    ThreadJList list = new ThreadJList(listModel, textArea);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                                    JScrollPane threadlistSP = new JScrollPane(list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                                    JScrollPane textAreaSP = new JScrollPane(textArea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                                    threadlistSP.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                                    textAreaSP.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                                    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                                                                                 threadlistSP, textAreaSP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                                    splitPane.setOneTouchExpandable(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                                    splitPane.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                                    splitPane.setDividerLocation(threadsSplitPane.getDividerLocation());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                                    String tabName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                                    if (deadlockedThreads.length > 1) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   474
                                        tabName = Resources.format(Messages.DEADLOCK_TAB_N, i+1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                                    } else {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   476
                                        tabName = Messages.DEADLOCK_TAB;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                                    threadListTabbedPane.addTab(tabName, splitPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                                    for (long t : deadlockedThreads[i]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                                        listModel.addElement(t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                                threadListTabbedPane.setSelectedIndex(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                    // Ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                } catch (UndeclaredThrowableException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                    vmPanel.getProxyClient().markAsDead();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    // Return deadlocked threads or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    public Long[][] getDeadlockedThreadIds() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        ProxyClient proxyClient = vmPanel.getProxyClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        ThreadMXBean threadMBean = proxyClient.getThreadMXBean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        long[] ids = proxyClient.findDeadlockedThreads();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        if (ids == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        ThreadInfo[] infos = threadMBean.getThreadInfo(ids, Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        List<Long[]> dcycles = new ArrayList<Long[]>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        List<Long> cycle = new ArrayList<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        // keep track of which thread is visited
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        // one thread can only be in one cycle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        boolean[] visited = new boolean[ids.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        int deadlockedThread = -1; // Index into arrays
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            if (deadlockedThread < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                if (cycle.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                    // a cycle found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                    dcycles.add(cycle.toArray(new Long[0]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                    cycle = new ArrayList<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                // start a new cycle from a non-visited thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                for (int j = 0; j < ids.length; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                    if (!visited[j]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                        deadlockedThread = j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                        visited[j] = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                if (deadlockedThread < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                    // done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            cycle.add(ids[deadlockedThread]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            long nextThreadId = infos[deadlockedThread].getLockOwnerId();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            for (int j = 0; j < ids.length; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                ThreadInfo ti = infos[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                if (ti.getThreadId() == nextThreadId) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                     if (visited[j]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                         deadlockedThread = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                     } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                         deadlockedThread = j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                         visited[j] = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                     break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        return dcycles.toArray(new Long[0][0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    // ActionListener interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        String cmd = ((AbstractButton)evt.getSource()).getActionCommand();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        if (cmd == "detectDeadlock") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            messageLabel.setText("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            detectDeadlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    // DocumentListener interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    public void insertUpdate(DocumentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        doUpdate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    public void removeUpdate(DocumentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        doUpdate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    public void changedUpdate(DocumentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        doUpdate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   588
    private class ThreadJList extends JList<Long> {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        private JTextArea textArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   591
        ThreadJList(DefaultListModel<Long> listModel, JTextArea textArea) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
            super(listModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
            this.textArea = textArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
            setBorder(thinEmptyBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
19567
11f4bac9b4f3 6417721: Thread list should not allow multiple selection
egahlin
parents: 14342
diff changeset
   598
            setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
19582
1cab3f8c48c7 6359971: Threads tab: Simple text to explain that one can click on a thread to get stack trace
egahlin
parents: 19567
diff changeset
   599
            textArea.setText(Messages.THREAD_TAB_INITIAL_STACK_TRACE_MESSAGE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            addListSelectionListener(ThreadTab.this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            setCellRenderer(new DefaultListCellRenderer() {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   602
                public Component getListCellRendererComponent(JList<?> list, Object value, int index,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                                                              boolean isSelected, boolean cellHasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                    if (value != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                        String name = nameCache.get(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                        if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                            name = value.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                        setText(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
                    return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            Dimension d = super.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            d.width = Math.max(d.width, 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            return d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    private class PromptingTextField extends JTextField implements FocusListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        private String prompt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        boolean promptRemoved = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        Color fg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        public PromptingTextField(String prompt, int columns) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            super(prompt, columns);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            this.prompt = prompt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            updateForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            addFocusListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
            setAccessibleName(this, prompt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        public void revalidate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            super.revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            updateForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        private void updateForeground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            this.fg = UIManager.getColor("TextField.foreground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            if (promptRemoved) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
                setForeground(fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
                setForeground(Color.gray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        public String getText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            if (!promptRemoved) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                return super.getText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
        public void focusGained(FocusEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            if (!promptRemoved) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                setText("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                setForeground(fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                promptRemoved = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        public void focusLost(FocusEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            if (promptRemoved && getText().equals("")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                setText(prompt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                setForeground(Color.gray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                promptRemoved = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    OverviewPanel[] getOverviewPanels() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        if (overviewPanel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            overviewPanel = new ThreadOverviewPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        return new OverviewPanel[] { overviewPanel };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    private static class ThreadOverviewPanel extends OverviewPanel {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        ThreadOverviewPanel() {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   690
            super(Messages.THREADS, threadCountKey,  Messages.LIVE_THREADS, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        private void updateThreadsInfo(long tlCount, long tpCount, long ttCount, long timeStamp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            getPlotter().addValues(timeStamp, tlCount);
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   695
            getInfoLabel().setText(Resources.format(infoLabelFormat, tlCount, tpCount, ttCount));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
}