Java 8 automatically using multicore?

后端 未结 2 610
天涯浪人
天涯浪人 2021-02-06 02:27

I did some tests a year ago concerning multicore with java 7. First I implemented some calculations only in the main thread (CPU usage showed that only one core did all the work

2条回答
  •  难免孤独
    2021-02-06 03:13

    I have experienced this situation too. In my case, it is the frequent garbage collection that causes a significant high (98%) CPU usage. As pointed out by several comments under the original questions, the java GC uses multi-threading by default.

    In my opinion, your program is not CPU bound. Therefore, it is not likely to fully use 4 cores. On the other hand, when there is not enough heap space allocated for your program, the frequent GC will easily exhaust the CPU resource. After increasing the heap size, everything is just fine.

提交回复
热议问题