kri shan wrote:Which give better performance for counter
What do you mean by better performance, is it accuracy, speed or something else altogether?
Pablo Abbate wrote:If you have multithreads, use AtomicInteger, if not, use the common increment.
I think the decision is a bit more complex than that.
It may be that the reads and writes are currently done from within synchronized blocks for other reasons we are not aware of or it maybe that the hit counter is only indicative and so (providing writes are done from within a synchronized block) occasionally being out by a few hits on reads may not be an issue.