Java int concurrency ++int equivalent to AtomicInteger.incrementAndGet()?
- by Finbarr
Are these two equivalent? In other words, are the ++ and -- operators atomic?
int i = 0;
return ++i;
AtomicInteger ai = new AtomicInteger(0);
return ai.incrementAndGet();