java.lang.OutOfMemoryError: unable to create new native thread
Solution:If you are getting this error, then you can try decreasing the memory allocated to heap (-Xmx) and/or decreasing the thread stack memory (-Xss). Increasing -Xmx (32bit systems) will leave less room for threads if it is being used, hence the opposite of the solution.
Remember the memory allocated using '-Xss' is the maximum memory allocated per thread, and usually it's in KB. Also too low -Xss value can cause java.lang.StackOverflowError. If you continue to get the same error, you probably have thread leak, fix the program.