web项目搞活动,每次定点抢购的时候就会特别的卡。166个线程....
web项目搞活动,每次定点抢购的时候就会特别的卡,166个线程,有详细的线程状态。
tomcat cpu不高10-20,我就想是不是线程多了的问题。。不知道代码那个地方会出这种问题
,我只有获得数据库连接的时候才用到了锁,这个有没有关系呢.....
帅哥美女们,请问我该怎么解决呢..先谢了啊
这是我测试线程的jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<title>Threads in ldcstudy.com</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>
http-8080-1(WAITING) : java.lang.Thread
C3P0PooledConnectionPoolManager[identityToken->gbrh6o8t1ikk0oolw26v9|2a3daabd, dataSourceName->antuso_itao]-HelperThread-#0(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
C3P0PooledConnectionPoolManager[identityToken->gbrh6o8t1ikk0oolw26v9|2a3daabd, dataSourceName->antuso_itao]-HelperThread-#1(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
C3P0PooledConnectionPoolManager[identityToken->gbrh6o8t1ikk0oolw26v9|2a3daabd, dataSourceName->antuso_itao]-HelperThread-#2(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
C3P0PooledConnectionPoolManager[identityToken->gbrh6o8t1ilb1a91y0725s|71a0b6f7, dataSourceName->antuso_itao]-AdminTaskTimer(TIMED_WAITING) : java.util.TimerThread
C3P0PooledConnectionPoolManager[identityToken->gbrh6o8t1ilb1a91y0725s|71a0b6f7, dataSourceName->antuso_itao]-HelperThread-#0(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
C3P0PooledConnectionPoolManager[identityToken->gbrh6o8t1ilb1a91y0725s|71a0b6f7, dataSourceName->antuso_itao]-HelperThread-#1(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
C3P0PooledConnectionPoolManager[identityToken->gbrh6o8t1ilb1a91y0725s|71a0b6f7, dataSourceName->antuso_itao]-HelperThread-#2(TIMED_WAITING) : com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread
TP-Processor536(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor617(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor668(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor694(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor697(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor705(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor713(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor752(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor769(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor770(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor772(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor787(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor793(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor806(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor812(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor815(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor827(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor828(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor833(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor834(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor836(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor838(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor840(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor844(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor850(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor853(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor856(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor857(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor862(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor864(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor865(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor868(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor869(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor870(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor873(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor874(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor877(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor881(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor882(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor883(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor884(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor886(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor892(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor896(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor898(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor899(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor901(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor902(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor905(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor908(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor909(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor911(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor912(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor914(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor915(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor916(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor917(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor918(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor919(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor920(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor921(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor922(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor923(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor924(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor926(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor927(WAITING) : org.apache.tomcat.util.threads.ThreadWithAttributes
TP-Processor928(RUNNABLE) : org.apache.tomcat.util.threads.ThreadWithAttributes
.......后面全是一样的(由于字数限制,这里不后写了)
[解决办法]
如果不着急: 慢慢写
如果着急: 写不好线程就别写,连接池和Servlet都是线程安全的,你写线程做毛用?
[解决办法]
有些测试工具可以测试加载性能 不知道JProfiler可不可以,可以尝试用一下这方面的工具
通过查看各部分加载时间来判断可能卡在什么地方,比如某个页面如果加载缓慢,可以推断出页面所需的数据迟迟不到位所致,数据不到位是因为同步的原因等等
另外内存小我觉得确实是个问题,频繁和大量的gc可能就会造成卡顿了
[解决办法]
你内存太小还是怎么的;。。。
return java.util.Arrays.asList(ts);
是不是这里要放到最上面去比较节省性能呀;
import pack="java.util.Arrays;
你再试试;