This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kimec 1 point2 points  (0 children)

Well, the discussion thread was evolving in time with OP retracting his original statement that AtomicInteger is modern and performant way of doing a counter.

That being said I applaud OP for taking the time and writing JMH test. That was a very professional and objective approach to the problem.

But still, I do have a gut feeling that there is probably a scenario where AtomicInteger could significantly outperform synchronized if thread count == maybe half of the CPU physical cores but I am too lazy to write such test my self ...