JAVA查看线程信息
2015-07-07 10:41
477 查看
在JDK1.5中,java.lang.Thread类新增了一个getAllStackTraces()方法用于获取虚拟机中所有线程的StackTraceElement对象。
for(Map.Entry<Thread, StackTraceElement[]> stackTrace : Thread.getAllStackTraces().entrySet()){ Thread thread = (Thread)stackTrace.getKey(); StackTraceElement[] stack = (StackTraceElement[])stackTrace.getValue(); if(thread.equals(Thread.currentThread())){ continue; } System.out.print("\n线程:"+thread.getName()+"\n"); for(StackTraceElement element: stack){ System.out.print("\t"+element+"\n"); } }
相关文章推荐
- spring注解
- Spring注解详解
- Java实现Html转PDF
- maven web 项目中启动报错java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener
- ubunut jdk 配置
- Java集合类详解
- Spring + Shiro
- java判断字符串是否为空
- Java注解
- eclipse内存设置
- (转载)Java并发编程:线程间协作的两种方式:wait、notify、notifyAll和Condition
- ubuntu中安装eclipse
- ubuntu中安装eclipse
- Eclipse右下角显示heap堆栈清理的图标
- 开发问题及解决--java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
- ubuntu中安装eclipse
- Spring4 与 Hibernate4 整合过程中的问题记录
- Spring 使用注解方式进行事务管理
- Java 运算符优先级
- Eclipse 常用快捷键 (动画讲解)