Agree for *variables*. Here, we have a class member, which has to be loaded, then incremented, then stored.
So as Bertrand, I stay on the safe side and synchronize.
Sylvain
I understand the desire for more metrics and instrumenting Cocoon so that you can get the information you desire, but I have a very serious caveat emptor here. The more synchronization you put into the system the less scalability you get. It comes at a very heavy price. See my blog for a word picture of thread contention:
http://www.jroller.com/comments/bloritsch/Weblog/fighting_over_resources
Keep in mind that the more order you try and impose on a chaotic atmosphere the more bottlenecks you introduce. The contention becomes more violent and the overall system slows down.
If you go this route, I highly recommend you place it inside a block that does not execute if debugging is not happening. For example:
if ( getLogger().isDebugEnabled() ) { // do synchronized instrumentation }
That way in production you do not have to pay the price later.