宁波青林闲庭二手房:一个用于列举所有线程的JSP页面,便于调试

来源:百度文库 编辑:中财网 时间:2024/05/05 21:58:11
一个用于列举所有线程的JSP页面,便于调试
红薯 发布于 2011年01月18日 18时, 3评/1011阅 ( 26人收藏, 收藏 )
顶0踩
这是一个用来显示应用中所有的线程以及其运行状态的JSP页面,无需其他Java类支持,扔到web项目中即可运行。
标签:JSP
[文件] thread.jsp ~ 888B    下载(146)
01
02
03Threads in oschina
04
08
09
10java.io.tmpdir:
11

    12
  • <%=System.getProperty("java.io.tmpdir")%>

  • 13

14

15Memory:
16

    17
  1. freeMemory=<%=Runtime.getRuntime().freeMemory()/(1024*1024)%>M

  2. 18    
  3. totalMemory=<%=Runtime.getRuntime().totalMemory()/(1024*1024)%>M

  4. 19    
  5. maxMemory=<%=Runtime.getRuntime().maxMemory()/(1024*1024)%>M

  6. 20

21

22Thread:
23

    24<%for(Thread t : list_threads()){%>
    25
  1. <%=t.getName()%>(<%=t.getState()%>) : <%=t.getClass().getName()%>

  2. 26<%}%>
    27

28<%!
29public static java.util.List list_threads(){
30    int tc = Thread.activeCount();
31    Thread[] ts = new Thread[tc];
32    Thread.enumerate(ts);
33    return java.util.Arrays.asList(ts);
34}
35%>
36
37
----------------------------------------
tomcat启动CPU占用很高,Tomcat -6.0.18版本
方小 发表于 1-18 17:42 11个月前, 5回/874阅, 最后回答: 11个月前 (1人收藏 ,收藏 |举报)
讨论区 ? 技术问答
顶0踩
开启tomcatCPU占用很高,一直降不下来,今天又好了,请问是为什么啊,谢谢
标签:Tomcat CPU
我想问同样的问题共0个人想要问同样的问题 补充话题说明?
按评价排序 | 显示最新答案 | 回页面顶部共有5个答案 我要回答?

游客 回答于 2011-01-18 18:25 (11个月前)
举报
我用的这个版本,没有问题。还是在商用。
换个6.0的最高版本试试。
有帮助(0) | 没帮助(0) | 评论(0) | 引用此答案

红薯 回答于 2011-01-18 18:56 (11个月前)
举报
一般这种问题多半是应用程序导致的。
首先看看CPU占用高的时候访问是否正常,我之前经常遇见这样的问题,多半是某处代码死循环导致。
有个办法你试试用下面这个jsp文件看看系统中的线程,看有没有那些跟应用有关的该退出的没退出的。
http://www.oschina.net/code/snippet_12_2917
有帮助(0) | 没帮助(0) | 评论(0) | 引用此答案

zhangyou1010 回答于 2011-01-18 20:09 (11个月前)
举报
引用来自#3楼“红薯”的帖子
一般这种问题多半是应用程序导致的。
首先看看CPU占用高的时候访问是否正常,我之前经常遇见这样的问题,多半是某处代码死循环导致。
有个办法你试试用下面这个jsp文件看看系统中的线程,看有没有那些跟应用有关的该退出的没退出的。
http://www.oschina.net/code/snippet_12_2917
请教红薯,是不是状态为TIMED_WAITING 的线程有问题?
有帮助(0) | 没帮助(0) | 评论(0) | 引用此答案

zhangyou1010 回答于 2011-01-18 20:43 (11个月前)
举报
Thread:
main(RUNNABLE) : java.lang.Thread
Timer-0(TIMED_WAITING) : java.util.TimerThread
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-1(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-2(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-3(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-4(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-5(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-7(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-8(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-9(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-10(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
ContainerBackgroundProcessor[StandardEngine[Catalina]](TIMED_WAITING) : java.lang.Thread
http-5666-Acceptor-0(RUNNABLE) : java.lang.Thread
TP-Processor1(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor2(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor3(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor4(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Monitor(TIMED_WAITING) : java.lang.Thread
Thread-13(TIMED_WAITING) : com.cache.CacheTimer
Thread-12(TIMED_WAITING) : com.cache.Cache
net.sf.ehcache.CacheManager@1daf0bf(TIMED_WAITING) : java.util.TimerThread
TP-Processor5(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor6(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor7(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor8(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor9(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor10(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor11(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor12(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor13(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor14(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor15(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor16(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor17(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor18(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor19(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor20(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor21(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor22(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor23(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor24(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor25(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor26(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor27(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor28(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
pool-1-thread-1(TIMED_WAITING) : java.lang.Thread
TP-Processor29(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor30(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor31(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor32(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
File Reaper(WAITING) : org.apache.commons.io.FileCleaningTracker$Reaper
TP-Processor33(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor34(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor35(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor36(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor37(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor38(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor39(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor40(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor41(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor42(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor43(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor44(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor45(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor46(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor47(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor48(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor49(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor50(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor51(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor52(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
org.springframework.scheduling.quartz.SchedulerFactoryBean#0_QuartzSchedulerThread(TIMED_WAITING) : org.quartz.core.QuartzSchedulerThread
有帮助(0) | 没帮助(0) | 评论(0) | 引用此答案

zhangyou1010 回答于 2011-01-18 20:51 (11个月前)
举报
刚看了下api,感觉还不是很明白。
线程状态。线程可以处于下列状态之一:
至今尚未启动的线程处于这种状态。
正在 Java 虚拟机中执行的线程处于这种状态。
受阻塞并等待某个监视器锁的线程处于这种状态。
无限期地等待另一个线程来执行某一特定操作的线程处于这种状态。
等待另一个线程来执行取决于指定等待时间的操作的线程处于这种状态。
已退出的线程处于这种状态。