When running a multithreaded Java + SWT application, the javaw process never loads the processor by more than 50% (the processor, respectively, is dual core). Checked on OS Windows. Is 50% load a real value? Or does the OS just divide the total CPU utilization by a Java application by the number of "available processors"? If real, then how to make a Java-machine work "for all 100"?
- Want 100% - make at least one more thread. Since I suspect only one thread in your program, it cannot load more than one kernel. Kernels 2, therefore not more than 50% of the total. - KoVadim
- oneThe man wrote that he has a multi-threaded application! - Barmaley
- So for sure, at the right moment I keep at least 2 streams. But the maximum that I see is 60% of the load. - Selden
- Give squeeze (in the sense of multithreading) from the code. In fact, a lot of resources (in the sense of parallel use of the CPU) can go to synchronization (I don't know, do you have it?). - avp
- It is possible and in a multi-threaded code to write so that it will load only 50% (for example, a classic of the genre - the thread calls an external method that is synchronized). - KoVadim
2 answers
Loading kernels depends on the version of the running JVM. More or less normal support for multi-core processors has been running since Java 1.6, it also makes sense to pay attention to the bit depth of a running JVM — x64 or x86. If the 64-bit axis makes sense to install both JREs, since different 64-bit or 32-bit JREs may be involved in different situations.
In general, the speed of JVM in multi-threaded applications is limited by the speed of object allocation (the so-called allocation wall) - read more simply by writing to RAM - that is, the bottleneck passes there. Read more here . In general, you must first "embroider" this side, and then you can talk about increasing the processor load.
- if there is one thread in the program (and there are no implicit others), then no matter how java strains, it will not work to load more than one kernel. (unless the compiler can figure out how to parallelize the code) - KoVadim
- @KoVadim I would not be so categorical ... JVM is able to load all the cores - just parallelization will not be at the level of threads / threads, but at the process level - Barmaley
- At the process level, this is understandable. I think if the vehicle launched two copies of its program, it would be completely 100% load :) - KoVadim
- Any application rarely has 1 process, so the irony is inappropriate :) - Barmaley
- You probably wanted to say "one thread". Otherwise, a little ironic. - KoVadim
Made. Barmaley was right, in my application large objects are turned over. They simply did not have time to create in memory. Did a normal job with memory, brought the max. download up to 98%. Thank you all for your help!