src/jdk.jconsole/share/classes/sun/tools/jconsole/ThreadTab.java
author dholmes
Mon, 09 Jul 2018 20:17:32 -0400
changeset 51020 1835f9fca157
parent 47216 71c04702a3d5
child 52902 e3398b2e1ab0
permissions -rw-r--r--
8205878: pthread_getcpuclockid is expected to return 0 code Reviewed-by: cjplummer, amenkov, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22094
diff changeset
     2
 * Copyright (c) 2004, 2014, 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
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
      Hierarchy of panels and layouts for this tab:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        ThreadTab (BorderLayout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            North:  topPanel (BorderLayout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                        Center: controlPanel (FlowLayout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                                    timeComboBox
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            Center: plotterPanel (BorderLayout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                        Center: plotter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public static String getTabName() {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
    87
        return Messages.THREADS;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public ThreadTab(VMPanel vmPanel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        super(vmPanel, getTabName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        setLayout(new BorderLayout(0, 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        setBorder(new EmptyBorder(4, 4, 3, 4));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        JPanel topPanel     = new JPanel(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        JPanel plotterPanel = new JPanel(new VariableGridLayout(0, 1, 4, 4, true, true));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        add(topPanel, BorderLayout.NORTH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        add(plotterPanel,  BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 5));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        topPanel.add(controlPanel, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   105
        threadMeter = new PlotterPanel(Messages.NUMBER_OF_THREADS,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                                       Plotter.Unit.NONE, true);
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   107
        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
   108
        threadMeter.plotter.createSequence(peakKey,        Messages.PEAK,         peakColor,        true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        setAccessibleName(threadMeter.plotter,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   110
                          Messages.THREAD_TAB_THREAD_PLOTTER_ACCESSIBLE_NAME);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        plotterPanel.add(threadMeter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        timeComboBox = new TimeComboBox(threadMeter.plotter);
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   115
        controlPanel.add(new LabeledComponent(Messages.TIME_RANGE_COLON,
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   116
                                              Resources.getMnemonicInt(Messages.TIME_RANGE_COLON),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                                              timeComboBox));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   119
        listModel = new DefaultListModel<Long>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        JTextArea textArea = new JTextArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        textArea.setBorder(thinEmptyBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        textArea.setEditable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        setAccessibleName(textArea,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   125
                          Messages.THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME);
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   126
        ThreadJList list = new ThreadJList(listModel, textArea);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        Dimension di = new Dimension(super.getPreferredSize());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        di.width = Math.min(di.width, 200);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        JScrollPane threadlistSP = new JScrollPane(list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        threadlistSP.setPreferredSize(di);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        threadlistSP.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        JScrollPane textAreaSP = new JScrollPane(textArea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        textAreaSP.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        threadListTabbedPane = new JTabbedPane(JTabbedPane.TOP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        threadsSplitPane  = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                                           threadlistSP, textAreaSP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        threadsSplitPane.setOneTouchExpandable(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        threadsSplitPane.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        JPanel firstTabPanel = new JPanel(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        firstTabPanel.setOpaque(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        JPanel firstTabToolPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 2));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        firstTabToolPanel.setOpaque(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        filterTF = new PromptingTextField("Filter", 20);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        filterTF.getDocument().addDocumentListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        firstTabToolPanel.add(filterTF);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        JSeparator separator = new JSeparator(JSeparator.VERTICAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        separator.setPreferredSize(new Dimension(separator.getPreferredSize().width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                                 filterTF.getPreferredSize().height));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        firstTabToolPanel.add(separator);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   159
        JButton detectDeadlockButton = new JButton(Messages.DETECT_DEADLOCK);
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   160
        detectDeadlockButton.setMnemonic(Resources.getMnemonicInt(Messages.DETECT_DEADLOCK));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        detectDeadlockButton.setActionCommand("detectDeadlock");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        detectDeadlockButton.addActionListener(this);
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   163
        detectDeadlockButton.setToolTipText(Messages.DETECT_DEADLOCK_TOOLTIP);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        firstTabToolPanel.add(detectDeadlockButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        messageLabel = new JLabel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        firstTabToolPanel.add(messageLabel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        firstTabPanel.add(threadsSplitPane, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        firstTabPanel.add(firstTabToolPanel, BorderLayout.SOUTH);
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   171
        threadListTabbedPane.addTab(Messages.THREADS, firstTabPanel);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        plotterPanel.add(threadListTabbedPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    private long oldThreads[] = new long[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    public SwingWorker<?, ?> newSwingWorker() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        final ProxyClient proxyClient = vmPanel.getProxyClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if (!plotterListening) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            proxyClient.addWeakPropertyChangeListener(threadMeter.plotter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            plotterListening = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        return new SwingWorker<Boolean, Object>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            private int tlCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            private int tpCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            private long ttCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            private long[] threads;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            private long timeStamp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            public Boolean doInBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                    ThreadMXBean threadMBean = proxyClient.getThreadMXBean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                    tlCount = threadMBean.getThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                    tpCount = threadMBean.getPeakThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    if (overviewPanel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                        ttCount = threadMBean.getTotalStartedThreadCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                        ttCount = 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    threads = threadMBean.getAllThreadIds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                    for (long newThread : threads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                        if (nameCache.get(newThread) == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                            ThreadInfo ti = threadMBean.getThreadInfo(newThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                            if (ti != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                                String name = ti.getThreadName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                                if (name != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                                    nameCache.put(newThread, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                    timeStamp = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                    return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                } catch (UndeclaredThrowableException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            protected void done() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                    if (!get()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                } catch (InterruptedException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                } catch (ExecutionException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                    if (JConsole.isDebug()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                        ex.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                threadMeter.plotter.addValues(timeStamp, tlCount, tpCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                threadMeter.setValueLabel(tlCount+"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                if (overviewPanel != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                    overviewPanel.updateThreadsInfo(tlCount, tpCount, ttCount, timeStamp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                String filter = filterTF.getText().toLowerCase(Locale.ENGLISH);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                boolean doFilter = (filter.length() > 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                ArrayList<Long> l = new ArrayList<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                for (long t : threads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                    l.add(t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                Iterator<Long> iterator = l.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                while (iterator.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                    long newThread = iterator.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                    String name = nameCache.get(newThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                    if (doFilter && name != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                        name.toLowerCase(Locale.ENGLISH).indexOf(filter) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                        iterator.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                long[] newThreads = threads;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                if (l.size() < threads.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                    newThreads = new long[l.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                    for (int i = 0; i < newThreads.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                        newThreads[i] = l.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                for (long oldThread : oldThreads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                    boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                    for (long newThread : newThreads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                        if (newThread == oldThread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                            found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                    if (!found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                        listModel.removeElement(oldThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                        if (!doFilter) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                            nameCache.remove(oldThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                // Threads are in reverse chronological order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                for (int i = newThreads.length - 1; i >= 0; i--) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                    long newThread = newThreads[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                    boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    for (long oldThread : oldThreads) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                        if (newThread == oldThread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                            found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                    if (!found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                        listModel.addElement(newThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                oldThreads = newThreads;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    long lastSelected = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    public void valueChanged(ListSelectionEvent ev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        ThreadJList list = (ThreadJList)ev.getSource();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        final JTextArea textArea = list.textArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 22094
diff changeset
   314
        Long selected = list.getSelectedValue();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        if (selected == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            if (lastSelected != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                selected = lastSelected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            lastSelected = selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        textArea.setText("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        if (selected != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            final long threadID = selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            workerAdd(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                    ProxyClient proxyClient = vmPanel.getProxyClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                    StringBuilder sb = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                        ThreadMXBean threadMBean = proxyClient.getThreadMXBean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                        ThreadInfo ti = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                        MonitorInfo[] monitors = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                        if (proxyClient.isLockUsageSupported() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                              threadMBean.isObjectMonitorUsageSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                            // VMs that support the monitor usage monitoring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                            ThreadInfo[] infos = threadMBean.dumpAllThreads(true, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                            for (ThreadInfo info : infos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                                if (info.getThreadId() == threadID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                                    ti = info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                                    monitors = info.getLockedMonitors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                            // VM doesn't support monitor usage monitoring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                            ti = threadMBean.getThreadInfo(threadID, Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                        if (ti != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                            if (ti.getLockName() == null) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   350
                                sb.append(Resources.format(Messages.NAME_STATE,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                                              ti.getThreadName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                                              ti.getThreadState().toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                            } else if (ti.getLockOwnerName() == null) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   354
                                sb.append(Resources.format(Messages.NAME_STATE_LOCK_NAME,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                                              ti.getThreadName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                                              ti.getThreadState().toString(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                                              ti.getLockName()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                            } else {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   359
                                sb.append(Resources.format(Messages.NAME_STATE_LOCK_NAME_LOCK_OWNER,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                                              ti.getThreadName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                                              ti.getThreadState().toString(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                                              ti.getLockName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                                              ti.getLockOwnerName()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                            }
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   365
                            sb.append(Resources.format(Messages.BLOCKED_COUNT_WAITED_COUNT,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                                              ti.getBlockedCount(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                                              ti.getWaitedCount()));
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   368
                            sb.append(Messages.STACK_TRACE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                            int index = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                            for (StackTraceElement e : ti.getStackTrace()) {
27957
24b4e6082f19 8055723: Replace concat String to append in StringBuilder parameters (dev)
weijun
parents: 25859
diff changeset
   371
                                sb.append(e).append('\n');
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                                if (monitors != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                                    for (MonitorInfo mi : monitors) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                                        if (mi.getLockedStackDepth() == index) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   375
                                            sb.append(Resources.format(Messages.MONITOR_LOCKED, mi.toString()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                                index++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                    } catch (IOException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                        // Ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                    } catch (UndeclaredThrowableException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                        proxyClient.markAsDead();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                    final String text = sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                    SwingUtilities.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                            textArea.setText(text);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                            textArea.setCaretPosition(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                }
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
    private void doUpdate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        workerAdd(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                update();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    private void detectDeadlock() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        workerAdd(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                    final Long[][] deadlockedThreads = getDeadlockedThreadIds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                    if (deadlockedThreads == null || deadlockedThreads.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                        // Display message for 30 seconds. Do it on a separate thread so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                        // the sleep won't hold up the worker queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                        // This will be replaced later by separate statusbar logic.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                        new Thread() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                            public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
                                    SwingUtilities.invokeAndWait(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                                        public void run() {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   423
                                            String msg = Messages.NO_DEADLOCK_DETECTED;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                                            messageLabel.setText(msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                                            threadListTabbedPane.revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                                    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                                    sleep(30 * 1000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                                } catch (InterruptedException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                                    // Ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                                } catch (InvocationTargetException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                                    // Ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                                SwingUtilities.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                                    public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                                        messageLabel.setText("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                                });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                        }.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                    SwingUtilities.invokeLater(new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                            // Remove old deadlock tabs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                            while (threadListTabbedPane.getTabCount() > 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                                threadListTabbedPane.removeTabAt(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                            if (deadlockedThreads != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                                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
   453
                                    DefaultListModel<Long> listModel = new DefaultListModel<Long>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                                    JTextArea textArea = new JTextArea();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                                    textArea.setBorder(thinEmptyBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                                    textArea.setEditable(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                                    setAccessibleName(textArea,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   458
                                                      Messages.THREAD_TAB_THREAD_INFO_ACCESSIBLE_NAME);
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   459
                                    ThreadJList list = new ThreadJList(listModel, textArea);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                                    JScrollPane threadlistSP = new JScrollPane(list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                                    JScrollPane textAreaSP = new JScrollPane(textArea);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                                    threadlistSP.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                                    textAreaSP.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                                    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                                                                                 threadlistSP, textAreaSP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                                    splitPane.setOneTouchExpandable(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                                    splitPane.setBorder(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                                    splitPane.setDividerLocation(threadsSplitPane.getDividerLocation());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                                    String tabName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                                    if (deadlockedThreads.length > 1) {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   471
                                        tabName = Resources.format(Messages.DEADLOCK_TAB_N, i+1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                                    } else {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   473
                                        tabName = Messages.DEADLOCK_TAB;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                                    threadListTabbedPane.addTab(tabName, splitPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
                                    for (long t : deadlockedThreads[i]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                                        listModel.addElement(t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
                                threadListTabbedPane.setSelectedIndex(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                    });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                    // Ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                } catch (UndeclaredThrowableException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                    vmPanel.getProxyClient().markAsDead();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        });
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
    // Return deadlocked threads or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    public Long[][] getDeadlockedThreadIds() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        ProxyClient proxyClient = vmPanel.getProxyClient();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        ThreadMXBean threadMBean = proxyClient.getThreadMXBean();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        long[] ids = proxyClient.findDeadlockedThreads();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        if (ids == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        ThreadInfo[] infos = threadMBean.getThreadInfo(ids, Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        List<Long[]> dcycles = new ArrayList<Long[]>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        List<Long> cycle = new ArrayList<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        // keep track of which thread is visited
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        // one thread can only be in one cycle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        boolean[] visited = new boolean[ids.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        int deadlockedThread = -1; // Index into arrays
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            if (deadlockedThread < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
                if (cycle.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                    // a cycle found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                    dcycles.add(cycle.toArray(new Long[0]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
                    cycle = new ArrayList<Long>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                // start a new cycle from a non-visited thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                for (int j = 0; j < ids.length; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                    if (!visited[j]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                        deadlockedThread = j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                        visited[j] = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
                if (deadlockedThread < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
                    // done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            cycle.add(ids[deadlockedThread]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            long nextThreadId = infos[deadlockedThread].getLockOwnerId();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
            for (int j = 0; j < ids.length; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
                ThreadInfo ti = infos[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                if (ti.getThreadId() == nextThreadId) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                     if (visited[j]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                         deadlockedThread = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                     } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
                         deadlockedThread = j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
                         visited[j] = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                     break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        return dcycles.toArray(new Long[0][0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
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
    // ActionListener interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    public void actionPerformed(ActionEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        String cmd = ((AbstractButton)evt.getSource()).getActionCommand();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        if (cmd == "detectDeadlock") {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            messageLabel.setText("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            detectDeadlock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    // DocumentListener interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    public void insertUpdate(DocumentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        doUpdate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    public void removeUpdate(DocumentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        doUpdate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    public void changedUpdate(DocumentEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        doUpdate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   585
    private class ThreadJList extends JList<Long> {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        private JTextArea textArea;
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
        ThreadJList(DefaultListModel<Long> listModel, JTextArea textArea) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            super(listModel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            this.textArea = textArea;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            setBorder(thinEmptyBorder);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
19567
11f4bac9b4f3 6417721: Thread list should not allow multiple selection
egahlin
parents: 14342
diff changeset
   595
            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
   596
            textArea.setText(Messages.THREAD_TAB_INITIAL_STACK_TRACE_MESSAGE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
            addListSelectionListener(ThreadTab.this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
            setCellRenderer(new DefaultListCellRenderer() {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   599
                public Component getListCellRendererComponent(JList<?> list, Object value, int index,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                                                              boolean isSelected, boolean cellHasFocus) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                    if (value != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                        String name = nameCache.get(value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                        if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                            name = value.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                        setText(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                    return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        public Dimension getPreferredSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            Dimension d = super.getPreferredSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
            d.width = Math.max(d.width, 100);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            return d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    private class PromptingTextField extends JTextField implements FocusListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        private String prompt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        boolean promptRemoved = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        Color fg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        public PromptingTextField(String prompt, int columns) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            super(prompt, columns);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
            this.prompt = prompt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            updateForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            addFocusListener(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            setAccessibleName(this, prompt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        public void revalidate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
            super.revalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            updateForeground();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        private void updateForeground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            this.fg = UIManager.getColor("TextField.foreground");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            if (promptRemoved) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
                setForeground(fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
                setForeground(Color.gray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        public String getText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            if (!promptRemoved) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                return super.getText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        public void focusGained(FocusEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
            if (!promptRemoved) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                setText("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                setForeground(fg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                promptRemoved = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        public void focusLost(FocusEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            if (promptRemoved && getText().equals("")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                setText(prompt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                setForeground(Color.gray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                promptRemoved = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    OverviewPanel[] getOverviewPanels() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        if (overviewPanel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            overviewPanel = new ThreadOverviewPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        return new OverviewPanel[] { overviewPanel };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    private static class ThreadOverviewPanel extends OverviewPanel {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        ThreadOverviewPanel() {
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   687
            super(Messages.THREADS, threadCountKey,  Messages.LIVE_THREADS, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        private void updateThreadsInfo(long tlCount, long tpCount, long ttCount, long timeStamp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
            getPlotter().addValues(timeStamp, tlCount);
22094
1c154d8a9a96 8030698: Several GUI labels in jconsole need correction
igerasim
parents: 19582
diff changeset
   692
            getInfoLabel().setText(Resources.format(Messages.THREAD_TAB_INFO_LABEL_FORMAT, tlCount, tpCount, ttCount));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
}