List of usage examples for java.lang Thread.State toString
public String toString()
From source file:serposcope.controllers.admin.AdminController.java
public Result stackdump(Context context) { return Results.contentType("text/plain").render((ctx, res) -> { ResponseStreams responseStreams = context.finalizeHeaders(res); try (PrintWriter writer = new PrintWriter(responseStreams.getOutputStream());) { final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); final ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds(), 100); for (ThreadInfo threadInfo : threadInfos) { writer.append('"'); writer.append(threadInfo.getThreadName()); writer.append("\" "); final Thread.State state = threadInfo.getThreadState(); writer.append("\n java.lang.Thread.State: "); writer.append(state.toString()); final StackTraceElement[] stackTraceElements = threadInfo.getStackTrace(); for (final StackTraceElement stackTraceElement : stackTraceElements) { writer.append("\n at "); writer.append(stackTraceElement.toString()); }//from w ww. ja v a 2 s . co m writer.println("\n"); } } catch (IOException ex) { LOG.error("stackdump", ex); } }); }