You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
question logic about ThreadUtil. getFullStacktrace(ThreadInfo threadInfo, double cpuUsage, long deltaTime, long time, int lockIdentityHashCode, int blockingThreadCount)
#2721
In arthas master branch. there is a logic that makes me confused in ThreadUtil. getFullStacktrace(ThreadInfo threadInfo, double cpuUsage, long deltaTime, long time, int lockIdentityHashCode, int blockingThreadCount)
for
(StackTraceElementste : threadInfo.getStackTrace()) {
sb.append("\tat ").append(ste.toString());
sb.append('\n');
if (i == 0 && threadInfo.getLockInfo() != null) {
Thread.Statets = threadInfo.getThreadState();
switch (ts) {
caseBLOCKED:
sb.append("\t- blocked on ").append(threadInfo.getLockInfo());
sb.append('\n');
break;
caseWAITING:
sb.append("\t- waiting on ").append(threadInfo.getLockInfo());
sb.append('\n');
break;
caseTIMED_WAITING:
sb.append("\t- waiting on ").append(threadInfo.getLockInfo());
sb.append('\n');
break;
default:
}
}
for (MonitorInfomi : threadInfo.getLockedMonitors()) {
if (mi.getLockedStackDepth() == i) {
sb.append("\t- locked ").append(mi);
if (mi.getIdentityHashCode() == lockIdentityHashCode) {
Ansihighlighted = Ansi.ansi().fg(Ansi.Color.RED);
highlighted.a(" <---- but blocks ").a(blockingThreadCount).a(" other threads!");
sb.append(highlighted.reset().toString());
}
sb.append('\n');
}
}
++i;
}
if (i < threadInfo.getStackTrace().length) {
sb.append("\t...");
sb.append('\n');
}
in the above codes, there is a for loop increasing i, then there is a test to check if i is smaller than threadInfo.getStackTrace().length.
my question is when will the test be true ?
is it possible that threadInfo.stackTrace can be changed by other thread?
how to reproduce it ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In arthas master branch. there is a logic that makes me confused in ThreadUtil. getFullStacktrace(ThreadInfo threadInfo, double cpuUsage, long deltaTime, long time, int lockIdentityHashCode, int blockingThreadCount)
in the above codes, there is a for loop increasing i, then there is a test to check if i is smaller than threadInfo.getStackTrace().length.
my question is when will the test be true ?
is it possible that threadInfo.stackTrace can be changed by other thread?
how to reproduce it ?
Beta Was this translation helpful? Give feedback.
All reactions