This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to create new native thread

 
Karthik Anant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Karthik Anant
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
the problem got resolved soon after running the program in 64 bit mode.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic