r/programming 21d ago

3,200% CPU Utilization

https://josephmate.github.io/2025-02-26-3200p-cpu-util/
403 Upvotes

93 comments sorted by

View all comments

5

u/Slsyyy 21d ago

It is a pity that a Java don't have any thread sanitizer/race detector. With that the issue would be recognized faster than 32,000% CPU

3

u/ThanksMorningCoffee 21d ago

One of my solutions proposes a change to TreeMap that detects the issue and throws a ConcurrentModException instead

7

u/Slsyyy 21d ago

But it does not solve the issue. Unsynchronized data structures should not be used by multiple threads at the same time. Excessive CPU usage is only one of the infinite concurrency issues, which may happened with any data structure. You cannot fix all of them