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.
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?
subject: Tomcat : Exception in thread ...... java.lang.OutOfMemoryError: unable to create new native thread