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


i have situation in need create thousands of instances of class third party api. each new instance creates new thread. start getting outofmemoryerror once threads more 1000. application requires creating 30,000 instances. each instance active time. application deployed on 64 bit linux box 8gb ram , 2 gb available application.

the way third party library works, cannot use new executor framework or thread pooling.

so how can solve problem?

note using thread pool not option. threads running time capture events.

sine memory size on linux box not in control if had choice have 25gb available application in 32gb system, solve problem or jvm still choke up?

are there optimal java settings above scenario ?

the system uses oracle java 1.6 64 bit.

i concur ryan's answer. problem worse analysis suggests.

hotspot jvms have hard-wired minimum stack size - 128k java 6 , 160k java 7.

that means if set stack size smallest possible value, you'd need use twice allocated space ... thread stacks.

in addition, having 30k native threads liable cause problems on operating systems.

i put task impossible. need find alternative design not require have 30k threads simultaneously. alternatively, need much larger machine run application.


reference: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2012-june/003867.html


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -