Can't get past 2542 Threads in Java on 4GB iMac OSX 10.6.3 Snow Leopard (32bit)?

I figured it out with some ideas from the other answers, 2542 seemed like an arbitrary number. I shut all programs down except the one terminal window I was running my test from and I got to 2545, that told me it was an arbitrary limit.

I figured it out with some ideas from the other answers, 2542 seemed like an arbitrary number. I shut all programs down except the one terminal window I was running my test from and I got to 2545, that told me it was an arbitrary limit. To get the number of threads for OSX 10.6.3 you do: > sysctl kern.

Num_threads kern. Num_threads: 2560 and > sysctl kern. Num_taskthreads kern.

Num_taskthreads: 2560 The 2560 number matches up with the 2542 and 2545 because there are obviously other threads running in the background. Unfortunately these settings can't be adjused in the desktop version of OSX.

At least in Linux sysctl has parameter -w and you can use such construction to change value: sysctl -w kern. Num_taskthreads=3000 These value is not persistent between restarts. – Lukasz Stelmach May 18 '10 at 22:43 doesn't work on OSX – Jarrod Roberson May 21 '10 at 18:53.

You need to find out the maximum number of threads the operating system supports on your system. On linux you can do something like : cat /proc/sys/kernel/threads-max to get the max, and to set it you can do something like : echo 10000 > /proc/sys/kernel/threads-max Also try running with : -XX:-UseBoundThreads and report back the results.

Nope not on linux and -XX:-UseBoundThreads doesn't change anything – Jarrod Roberson May 18 '10 at 21:33 see my answer on how to get the max threads for OSX – Jarrod Roberson May 18 '10 at 21:53.

According to the Apple Developer doc the thread stack size should be at least 64K, so your -Xss 1014 is ignored. But even with 64K per thread, the thread stack memory consumption comes only to about 160MB, so this shouldn't be the problem. Threads could also consume memory from a more limited pool, or there could simply be limit on the number of thread you can have per process or user.

I set it to 256k and it still fails at the exact same number of threads. Java -Xss256k -XX:ThreadStackSize=256 TestThreadStackSizes 10000 – Jarrod Roberson May 18 '10 at 21:44.

I don't think so. I have worked in application which processed hundreds of documents, convert them from and to diff. Format, generates proper logs in DB and stores specific info also.

Then also it finished in seconds. The thing you should take care about it, code wisely to avoid making too much threads. Instead use a ThreadPool provided by Java, so that same threads can be utilized when needed.

That will provide better performance. Also keep synchronization on minimal blocks to avoid bottle necks in your execution.Thanks.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions