我在我的應用程序中使用jsp-servlet。並在jboss 7.0.2服務器上部署了這場戰爭。我有servlet有與數據庫相關的代碼,並被稱爲許多時間在秒(比如說500次)。但是對於這麼多的線程來說,jboss 7.0.2將無法處理這些線程。jboss7,java.lang.OutOfMemoryError:無法創建新的本地線程
我正在使用64位jvm。
我用-Xss256k減少了線程堆棧的大小,這對我不起作用。
我的確在jboss.conf
wrapper.java.additional.10 = -XX配置:ThreadStackSize = 256K
我需要處理上jboss7的2000多個線程。
服務器(jboss7.0.2)引發異常。
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Unknown Source)
這裏是我的servlet java.lang.OutOfMemoryError:無法創建新的本地線程
public class Test extends HttpServlet {
private static final long serialVersionUID = 1L;
public Test() {
super();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
public void processRequest(HttpServletRequest request,
HttpServletResponse response) {
Logger log=LoggerFactory.getLogger(feedback.class);
/* here is my code to insert the data in database. */
TestClass testobj = new TestClass();
testobj.setparam("");
smsmanager1.add(sms);
smsmanager1 = null;
sms = null;
}
}
代碼FOT添加方法
public void add(T obj) {
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session=sessionFactory.openSession();
Transaction transaction = null;
try {
transaction = session.beginTransaction();
session.save(obj);
transaction.commit();
session.flush();
} catch (HibernateException e) {
if(transaction!=null){
transaction.rollback();}
e.printStackTrace();
} finally {
if(session!=null){
session.close();}
session = null;
transaction = null;
}
我爲有空白的servlet測試唯一一個控制檯打印語句。它工作正常,但它不適用於上面的servlet。
我在正確的軌道上嗎?
服務器如何處理500-800線程以上的這種servlet?