String (long threadId) { if (threadId == Thread.currentThread().getId()) { return "<Activity Monitor>"; } ThreadInfo info = threadBean.getThreadInfo(threadId, Integer.MAX_VALUE); if (info == null) return "<unidentified: thread finished>"; boolean runnable = info.getThreadState() == Thread.State.RUNNABLE; if (runnable) { for (StackTraceElement element : info.getStackTrace()) { String className = element.getClassName(); if (!isInfrastructureClass(className)) { return classToSubsystem.computeIfAbsent(className, this::calcSubSystemName); } } } return (runnable ? "<infrastructure: " : "<unidentified: ") + getCommonThreadName(info) + ">"; }