mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
fix thread command cause application InterruptedException problem. #1175
This commit is contained in:
@@ -52,7 +52,10 @@ public class ThreadCommand extends AnnotatedCommand {
|
||||
private int sampleInterval = 100;
|
||||
private String state;
|
||||
|
||||
{
|
||||
private boolean lockedMonitors = false;
|
||||
private boolean lockedSynchronizers = false;
|
||||
|
||||
static {
|
||||
states = new HashSet<String>(State.values().length);
|
||||
for (State state : State.values()) {
|
||||
states.add(state.name());
|
||||
@@ -89,6 +92,18 @@ public class ThreadCommand extends AnnotatedCommand {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Option(longName = "lockedMonitors", flag = true)
|
||||
@Description("Find the thread info with lockedMonitors flag, default value is false.")
|
||||
public void setLockedMonitors(boolean lockedMonitors) {
|
||||
this.lockedMonitors = lockedMonitors;
|
||||
}
|
||||
|
||||
@Option(longName = "lockedSynchronizers", flag = true)
|
||||
@Description("Find the thread info with lockedSynchronizers flag, default value is false.")
|
||||
public void setLockedSynchronizers(boolean lockedSynchronizers) {
|
||||
this.lockedSynchronizers = lockedSynchronizers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(CommandProcess process) {
|
||||
Affect affect = new RowAffect();
|
||||
@@ -176,7 +191,7 @@ public class ThreadCommand extends AnnotatedCommand {
|
||||
int status = 0;
|
||||
Map<Long, Long> topNThreads = ThreadUtil.getTopNThreads(sampleInterval, topNBusy);
|
||||
Long[] tids = topNThreads.keySet().toArray(new Long[0]);
|
||||
ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(ArrayUtils.toPrimitive(tids), true, true);
|
||||
ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(ArrayUtils.toPrimitive(tids), lockedMonitors, lockedSynchronizers);
|
||||
if (threadInfos == null) {
|
||||
process.write("thread do not exist! id: " + id + "\n");
|
||||
status = 1;
|
||||
@@ -192,7 +207,7 @@ public class ThreadCommand extends AnnotatedCommand {
|
||||
private int processThread(CommandProcess process) {
|
||||
int status = 0;
|
||||
String content;
|
||||
ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(new long[]{id}, true, true);
|
||||
ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(new long[]{id}, lockedMonitors, lockedSynchronizers);
|
||||
if (threadInfos == null || threadInfos[0] == null) {
|
||||
content = "thread do not exist! id: " + id + "\n";
|
||||
status = 1;
|
||||
|
||||
Reference in New Issue
Block a user