This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Threads and Synchronization and the fly likes unable to create new native thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "unable to create new native thread" Watch "unable to create new native thread" New topic
Author

unable to create new native thread

Karthik Anant
Greenhorn

Joined: Nov 02, 2009
Posts: 20
Hi all,
Am trying to spawn a new thread for every client that is connecting to my application. At present am not able to spawn more than 1085 threads, beyond which am getting the below exception. I am using HP UX 11.31 64 bit machine

Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:574)
at poc.MultipleThreadSpawning.main(MultipleThreadSpawning.java:15)

Would greatly appreciate any insights to overcome this problem.

Thanks in advance
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

Did you look up the description for: java.lang.OutOfMemoryError
Did you understand it?
Did you increase the memory for the JVM with switches? (-Xm...)

Using thousands of threads is usually a sign of bad design. Try reading about RMI and how it uses/reuses threads for each client call.


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
Karthik Anant
Greenhorn

Joined: Nov 02, 2009
Posts: 20
Thanks for the reply

yes, apart from increasing the -Xmx i've tried giving a lower value for it as well to make more memory available for native kernel.

i just said clients to indicate that its not a bad design and i cannot do away with the thousand threads running. I use TCP and hence i manage the socket output stream in a thread for each client connection. So nothing to do with RMI here.

The issue is more related to the HP UX 11.3 machine, as the same program runs fine in other OS such as AIX.
Karthik Anant
Greenhorn

Joined: Nov 02, 2009
Posts: 20
hi all,
the problem got resolved soon after running the program in 64 bit mode.
 
Don't get me started about those stupid light bulbs.
 
subject: unable to create new native thread