< prev index next > src/java.base/share/classes/jdk/internal/vm/ThreadDumper.java
Print this page
container.threads().forEach(t -> dumpThread(t, writer));
container.children().forEach(c -> dumpThreads(c, writer));
}
private static boolean dumpThread(Thread thread, TextWriter writer) {
! ThreadSnapshot snapshot = ThreadSnapshot.of(thread);
if (snapshot == null) {
! return false; // thread terminated
}
Instant now = Instant.now();
Thread.State state = snapshot.threadState();
writer.println("#" + thread.threadId() + " \"" + snapshot.threadName()
+ "\" " + (thread.isVirtual() ? "virtual " : "") + state + " " + now);
container.threads().forEach(t -> dumpThread(t, writer));
container.children().forEach(c -> dumpThreads(c, writer));
}
private static boolean dumpThread(Thread thread, TextWriter writer) {
! ThreadSnapshot snapshot = ThreadSnapshot.of(thread, true);
if (snapshot == null) {
! return false; // thread not alive
}
Instant now = Instant.now();
Thread.State state = snapshot.threadState();
writer.println("#" + thread.threadId() + " \"" + snapshot.threadName()
+ "\" " + (thread.isVirtual() ? "virtual " : "") + state + " " + now);
* @return true if the thread dump was written, false otherwise
* @throws UncheckedIOException if an I/O error occurs
*/
private static boolean dumpThread(Thread thread, JsonWriter jsonWriter) {
Instant now = Instant.now();
! ThreadSnapshot snapshot = ThreadSnapshot.of(thread);
if (snapshot == null) {
! return false; // thread terminated
}
Thread.State state = snapshot.threadState();
StackTraceElement[] stackTrace = snapshot.stackTrace();
jsonWriter.startObject();
* @return true if the thread dump was written, false otherwise
* @throws UncheckedIOException if an I/O error occurs
*/
private static boolean dumpThread(Thread thread, JsonWriter jsonWriter) {
Instant now = Instant.now();
! ThreadSnapshot snapshot = ThreadSnapshot.of(thread, true);
if (snapshot == null) {
! return false; // thread not alive
}
Thread.State state = snapshot.threadState();
StackTraceElement[] stackTrace = snapshot.stackTrace();
jsonWriter.startObject();
< prev index next >