像这样调用的EXE执行完后是不是自动结束了线程,我在TOMCAT里调用这个方法时,调用太多出现了线程超出一百五十最大值情况,在JAVA里运行没有问题,怎么做才能使TOMCAT不报这个线程超出的错,是不是我的EXE调用时没有结束线程,应该怎么结束?怎么优化下面的代码
public class kkd extends Thread {
private String llkd="";
public kkd (String oo){
this.llkd=oo;
}
public void run() {
try {
 Process cmpp = Runtime.getRuntime().exec("cmd.exe  /c  start ping 192.168.0.1  ");
} catch (Exception s) {
System.out.println("出错:" + s.toString());
}}
public static void main(String[] args) {
         Thread startthread=null;    
       for (int i=0;i<1000;i++){
         startthread  =new kkd ("192.168.0.1");
         startthread .start(); 
                }
    }
}

解决方案 »

  1.   

    这和Tomcat本身相关, 像Tomcat这样的web server为了保证性能, 它对线程的数目有一个限制.你应该可以通过修改tomcat的配置文件更改它的最大线程数. 另外,对于线程编程来说,并不是建立越多的线程,性能就会越高,因为每个线程是需要占用资源的(比如说内存) ,所以当线程的数目超过一个数值时,系统整体性能反而会出现下降. 现在进行线程编程时,为了建立健壮的多线程程序,可以去看看有关线程池(thread pool)的概念。在jdk1.5里面已经支持线程池了。
      

  2.   

    2005-9-19 17:12:38 org.apache.tomcat.util.threads.ThreadPool logFull
    严重: All threads (150) are currently busy, waiting. Increase maxThreads (150) or check the servlet status
      

  3.   

    2005-9-19 17:12:38 org.apache.tomcat.util.threads.ThreadPool logFull
    严重: All threads (150) are currently busy, waiting. Increase maxThreads (150) or check the servlet status
      

  4.   

    如果需要修改 tomcat,可以在在server.xml中 修改 maxThreads 属性。
      

  5.   

    这是进程,不是线程
    不知道你是在tomcat里怎么调用的,给出的信息不够
      

  6.   

    <Connector 
    port="80"               maxThreads="1500" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   debug="0" connectionTimeout="20000" 
                   disableUploadTimeout="true" />
      

  7.   

    TOMCAT:严重: Caught exception (java.lang.OutOfMemoryError: unable to create new native thread) executing org.apache.tomcat.util.net.TcpWorkerThread@190d8e1, terminating thread
      

  8.   

    我是在另一台机子上
    for(int i=0;in<100000;i++){
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE  http://192.168.0.1/1.asp");
    }
      

  9.   

    Tomcat为了保证性能, 对线程的数目有限制
      

  10.   

    你这样做相当于至少同时有几十万的用户访问tomcat,tomcat不一定能受得了,你把tomcat的maxthread改为1000000试试。最好把那些什么minSpareThreads,maxSpareThreads,acceptCount等等统统改了。