i saw comment like this
one place i have seen this problem is if you keep creating threads, and instead of calling start(), call run() directly on the thread object.
This will result in the thread object not getting dereferenced…
So after sometime the message unable to create new native thread comes up
on the Sun Java Forums
In my application, initialy we plan to use thread, but later, we decided no need anymore, so we just call run() instead of start(). Do we need to do manual GC for new threadClass(..) ?
my tomcat startup setting
-Xms1024m -Xmx1024m -XX:MaxPermSize=450m
Why do you create a
Threadin the first place?Your code should implement the
Runnableinterface instead.Then, when you decide that you want to run it in a thread, simple instantiate a
Threadwith theRunnableas the argument and callstart()on theThreadobject.If, instead, you just want to run it in your current thread, simply call
run()on yourRunnableobject.This has several advantages:
Threadobjects as long as you don’t care about separate threadsRunnablewhich fits closer conceptually: you’re not writing some special kind of Thread, do you? You simply write some code that can be executed/run.Executorwhich further abstract away the decisionAnd last but not least you avoid any potential confusion on whether or not a native thread resource is created.