Thursday, 15 August 2013

How to handle thousands of threads in Java without using the new java.util.concurrent package

How to handle thousands of threads in Java without using the new
java.util.concurrent package

I have a situation in which I need to create thousands of instances of a
class from third party API. Each new instance creates a new thread. I
start getting OutOfMemoryError once threads are more than 1000. But my
application requires creating 30,000 instances. Each instance is active
all the time. The application is deployed on a 64 bit linux box with 8gb
RAM and only 2 gb available to my application.
The way the third party library works, I cannot use the new Executor
framework or thread pooling.
So how can I solve this problem?
Are there some optimal Java settings for the above scenario ?

No comments:

Post a Comment