Just don't worry. Unless you are writing something like a Forex platform or something, that tiny, tiny latency will not matter. To give you an idea, we'd be talking at the order of nano seconds, whereas in application code we usually talk in milliseconds. Further, locks of JVM has improved significantly. If you have low contention (which is the norm), the performance difference between lock based solution and non-blocking solution would be tiny.
Surprising though that IBM JVM uses a lock for AtomicLong. I thought all major implementation uses non-blocking CAS. Here is the common implementation which uses CAS:
/**
* Atomically increments by one the current value.
*
* @return the updated value
*/
public final long incrementAndGet() {
for (;;) {
long current = get();
long next = current + 1;
if (compareAndSet(current, next))
return next;
}
}
Response to follow up comment:
As a very rough rule of thumb, if your current end-to-end response time (or the response time requirement) is over 30ms, I really would not worry about this as whatever time spent incrementing the long would be in the realm of nanoseconds. I'm almost certain that you'll find other places to optimise that gives you more improvement (e.g. milliseconds).
However, you could just copy the Sun JVM implementation of AtomicLong to use the non-blocking implementation to use instead, as IBM VM should have CAS operations, too. This is only likely to result in significant improvement if you expect moderate to high contention (lots of threads). If you don't, I think the locking solution can perform nearly identically with the current, improvement lock implementation (available from JDK6, if I remember).
In fact, if you have very high contention, a lock can perform BETTER than a non-blocking solution. So you'd ideally have to use two implementation and compare the results... which is kinda why I think you shouldn't bother, because in that time, you could have made a few performance improvements elsewhere that gives you literary more than 1 mil times the improvement you could attain through tackling here.