Java thread how many




















Please keep in mind, that you will be able to reproduce the results only on modern operating systems and JVMs. I am afraid that Windows XP results will be much worse. Please also note, that once the threads are created and all of them sleep, the application does not consume any CPU and it consumes around MB of memory. I am not sure why so much memory is used, it has to be investigated.

As we have seen, in this artificial scenario threads are relatively cheap. I do not want to say, that we should not use new libraries or tools. Most of them are quite useful. The only thing I want to say is that we should think twice before prematurely optimizing our applications. Sometimes the most straightforward and easiest approach is the best. I recommend to play with JVM settings — the most important for amount of threads is the stacktrace frame size -Xss.

We have to use this setting on Sun Solaris to handle much more threads in production. In this case the threads are handling estabilished connections, so they are active and waiting for a time slice.

IA Yes of course, I just wanted to say that it does not make much sense to create thousands of threads that actively use CPU for most of the time. Switching overhead would be just too big. When I set -Xss64K everything looked same including memory consumption. Error thrown when creating thread java. Thanks for visiting DZone today,. Edit Profile. Sign Out View Profile. Over 2 million developers have joined DZone.

Like 1. Ask Question. Asked 9 years, 8 months ago. Active 9 years, 8 months ago. Viewed 6k times. Improve this question. Christian Neverdal 3 3 silver badges 14 14 bronze badges.

I bet you won't like Erlang. It depends on where you are bound. More threads than cores is not really all that bad. Hi David, all questions here are expected to be asked in a fair and impartial tone: ranting is not what we do here. If you can rephrase your question to something that's specifically answerable that doesn't doesn't contain a rant, feel free to do so and flag your question for moderator review.

So you are saying most of the complex software we use is wrong? Looking at Firefox on my mac with 2 tabs open I see it is running 26 threads How many threads can a Java VM support? Does this vary by vendor? This depends on the CPU you're using, on the OS, on what other processes are doing, on what Java release you're using, and other factors. Most of the threads were not doing anything, of course.

Once the machine hit about Threads in Java , the whole machine started to have difficulties and become weak.



0コメント

  • 1000 / 1000