Java tutorial
//package com.java2s; import java.awt.EventQueue; public class Main { /** * Print diagnostic info about the current thread. */ public static void printThreadInfo() { Thread thread = Thread.currentThread(); System.out.printf(" Thread id: %d, name: %s, state: %s, daemon: %s, EDT: %s\n", thread.getId(), thread.getName(), thread.getState(), thread.isDaemon(), EventQueue.isDispatchThread()); ThreadGroup group = thread.getThreadGroup(); System.out.printf(" priority: %d, group: %s, group count: %d\n", thread.getPriority(), group.getName(), group.activeCount()); StackTraceElement[] backtrace = thread.getStackTrace(); if (backtrace.length > 2) { System.out.printf(" trace[2]: %s\n", backtrace[2]); } } /** * Print diagnostic info about the current thread along with a header * message. * * @param message * - a header message. */ public static void printThreadInfo(String message) { System.out.printf("Note: %s\n", message); printThreadInfo(); } }