java.lang.OutOfMemoryError: unable to create new native thread
Unfortunately the OOM Exception is a bit confusing, see Java API for this :(
It mean that the JVM is out of system resource, in your case could not start a new thread.
There are two reasons:
- restriction to thread resources or filedescriptor
- could not get memory for thread stack (this memory is not included in your -Xmx512m, it will be allocated extra)