tomcat启动CPU占用很高

这是一个用来显示应用中所有的线程以及其运行状态的JSP页面,无需其他Java类支持,扔到web项目中即可运行。<html>

< head >
< title >Threads in oschina</ title >
< style >
body {font-size:8pt;}
ol {line-height:18px;}
</ style >
</ head >
< body >
< strong >java.io.tmpdir:</ strong >
< ul >
< li ><%=System.getProperty("java.io.tmpdir")%></ li >
</ ul >
< br />
< strong >Memory:</ strong >
< ol >
< li >freeMemory=<%=Runtime.getRuntime().freeMemory()/(1024*1024)%>M</ li >
     < li >totalMemory=<%=Runtime.getRuntime().totalMemory()/(1024*1024)%>M</ li >
     < li >maxMemory=<%=Runtime.getRuntime().maxMemory()/(1024*1024)%>M</ li >
</ ol >
< br />
< strong >Thread:</ strong >
< ol >
<%for(Thread t : list_threads()){%>
< li ><%=t.getName()%>(< b ><%=t.getState()%></ b >) : <%=t.getClass().getName()%></ li >
<%}%>
</ ol >
<%!
public static java.util.List< Thread > list_threads(){
     int tc = Thread.activeCount();
     Thread[] ts = new Thread[tc];
     Thread.enumerate(ts);
     return java.util.Arrays.asList(ts);
}
%>
</ body >
</ html >
 
-----------------------------------------------------------------

很多朋友碰到怎样的问题:tomcat启动CPU占用很高,Tomcat -6.0.18版本,本网通过互联网收集了以下的答案,以方便用户参考解决问题,具体问题如下:

 

开启tomcatCPU占用很高,一直降不下来,今天又好了,请问是为什么啊,谢谢

 

用户提供的答案1:

 

我用的这个版本,没有问题。还是在商用。

 

换个6.0的最高版本试试。

 

 

用户提供的答案2:

 

一般这种问题多半是应用程序导致的。

 

首先看看CPU占用高的时候访问是否正常,我之前经常遇见这样的问题,多半是某处代码死循环导致。

 

有个办法你试试用下面这个jsp文件看看系统中的线程,看有没有那些跟应用有关的该退出的没退出的。

 

http://www.oschina.net/code/snippet_12_2917

 

 

用户提供的答案3:

 

引用来自#3楼“红薯”的帖子

 

一般这种问题多半是应用程序导致的。

 

首先看看CPU占用高的时候访问是否正常,我之前经常遇见这样的问题,多半是某处代码死循环导致。

 

有个办法你试试用下面这个jsp文件看看系统中的线程,看有没有那些跟应用有关的该退出的没退出的。

 

http://www.oschina.net/code/snippet_12_2917

 

 

用户提供的答案4:

 

Thread:

  1. main(RUNNABLE) : java.lang.Thread
  2. Timer-0(TIMED_WAITING) : java.util.TimerThread
  3. com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
  4. com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
  5. com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
  6. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-1(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  7. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-2(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  8. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-3(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  9. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-4(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  10. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-5(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  11. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  12. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-7(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  13. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-8(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  14. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-9(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  15. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-10(TIMED_WAITING) : org.quartz.simpl.SimpleThreadPool$WorkerThread
  16. ContainerBackgroundProcessor[StandardEngine[Catalina]](TIMED_WAITING) : java.lang.Thread
  17. http-5666-Acceptor-0(RUNNABLE) : java.lang.Thread
  18. TP-Processor1(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  19. TP-Processor2(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  20. TP-Processor3(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  21. TP-Processor4(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  22. TP-Monitor(TIMED_WAITING) : java.lang.Thread
  23. Thread-13(TIMED_WAITING) : com.cache.CacheTimer
  24. Thread-12(TIMED_WAITING) : com.cache.Cache
  25. net.sf.ehcache.CacheManager@1daf0bf(TIMED_WAITING) : java.util.TimerThread
  26. TP-Processor5(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  27. TP-Processor6(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  28. TP-Processor7(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  29. TP-Processor8(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  30. TP-Processor9(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  31. TP-Processor10(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  32. TP-Processor11(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  33. TP-Processor12(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  34. TP-Processor13(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  35. TP-Processor14(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  36. TP-Processor15(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  37. TP-Processor16(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  38. TP-Processor17(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  39. TP-Processor18(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  40. TP-Processor19(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  41. TP-Processor20(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  42. TP-Processor21(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  43. TP-Processor22(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  44. TP-Processor23(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  45. TP-Processor24(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  46. TP-Processor25(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  47. TP-Processor26(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  48. TP-Processor27(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  49. TP-Processor28(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  50. pool-1-thread-1(TIMED_WAITING) : java.lang.Thread
  51. TP-Processor29(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  52. TP-Processor30(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  53. TP-Processor31(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  54. TP-Processor32(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  55. File Reaper(WAITING) : org.apache.commons.io.FileCleaningTracker$Reaper
  56. TP-Processor33(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  57. TP-Processor34(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  58. TP-Processor35(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  59. TP-Processor36(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  60. TP-Processor37(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  61. TP-Processor38(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  62. TP-Processor39(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  63. TP-Processor40(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  64. TP-Processor41(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  65. TP-Processor42(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  66. TP-Processor43(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  67. TP-Processor44(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  68. TP-Processor45(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  69. TP-Processor46(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  70. TP-Processor47(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  71. TP-Processor48(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  72. TP-Processor49(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  73. TP-Processor50(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
  74. TP-Processor51(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  75. TP-Processor52(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
  76. org.springframework.scheduling.quartz.SchedulerFactoryBean#0_QuartzSchedulerThread(TIMED_WAITING) : org.quartz.core.QuartzSchedulerThread 

 

 
 

用户提供的答案5: 

 

 

 

刚看了下api,感觉还不是很明白。 

 

 

 

线程状态。线程可以处于下列状态之一:

  • NEW
     

    至今尚未启动的线程处于这种状态。

  • RUNNABLE

     

     

    正在 Java 虚拟机中执行的线程处于这种状态。

  • BLOCKED
     

    受阻塞并等待某个监视器锁的线程处于这种状态。

  • WAITING 
     

     

    无限期地等待另一个线程来执行某一特定操作的线程处于这种状态。

  • TIMED_WAITING
     

    等待另一个线程来执行取决于指定等待时间的操作的线程处于这种状态。

  • TERMINATED
     已退出的线程处于这种状态。  

你可能感兴趣的:(tomcat启动CPU占用很高)