java输出当前线程信息,java当前线程,package cn.o
分享于 点击 1034 次 点评:25
java输出当前线程信息,java当前线程,package cn.o
package cn.outofmemory.snippets.core;public class CurrentThreadExample { public static void main(String[] args) { Thread thread = Thread.currentThread(); System.out.println("Thread: " + thread); System.out.println("Thread Id: " + thread.getId()); System.out.println("Thread Name: " + thread.getName()); System.out.println("Thread Group: " + thread.getThreadGroup()); System.out.println("Thread Priority: " + thread.getPriority()); }}
输出:
Thread: Thread[main,5,main]Thread Id: 1Thread Name: mainThread Group: java.lang.ThreadGroup[name=main,maxpri=10]Thread Priority: 5
用户点评