On Tue, May 12, 2009 at 6:27 AM, Caldarale, Charles R <chuck.caldar...@unisys.com> wrote: >> From: David Kerber [mailto:dcker...@verizon.net] >> Subject: Re: Performance with many small requests >> >> Incrementing a counter can't be much of a synchronization bottleneck, >> and if I switch to an AtomicInteger, it should be even less of one. > > Actually, it won't. There's a slight performance difference between the two > mechanisms, but it's usually in favor of the synchronized increment, not the > >AtomicInteger, at least on my dual-core AMD 64 system running JDK 6u12 in > 64-bit server mode on Vista. The difference is only a few percent, so you > should >just code it whichever way you find more maintainable. (Test program > available on request; it would be interesting to see if the same relationship > exists on a >modern Intel chip.)
Hello, last time I checked (which is a while ago - 2006 and on 1.5) it was not only processor, but also OS dependent and clearly in favor of atomics (but it probably depends on the number of concurrent writers too). If you would share your test code, I would love to test it on some *nixes and darwins I have here; i'd also volunteer to gather and publish results from everyone else :-) regards Leon --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org