I am using Tomcat server. On running multiple threads several times in my application I am getting error "java.lang.OutOfMemoryError: unable to create new native thread". Using method Thread.activeCount() I tried to get active thread count each time . I found out that as the thread were started, thread count gradually increased. But even though their respective run() mehtod is getting over, still the count of active thread is still same. Thus after creating several threads, the active count exceed a certain limit and the tomcat is crashing.
Thank you in advance.
Author and all-around good cowpoke
posted 5 years ago
Tomcat creates a pool of Threads to handle requests, you can configure the maximun number in server.xml - as I recall, the default is 150.
You should only be creating threads in your application if your really really know what you are doing.
What is the Thread count you get by calling activeCount?
Yes the max thread limit is 150 but in case of my sever.xml file that line is commented. Is there any way that the thread count can be controlled through programming. Since destroy() and suspend() methods are deprecated any other way to destroy the thread?