The javadoc for the java.util.concurrent.atomic package says the following:
A small toolkit of classes that support lock-free thread-safe programming on single variables.
But I don't see any thread-safe (synchronized or Lock) code inside any of the AtomicInteger or AtomicBoolean classes.
So, are these 2 the same:
1.
int i;synchronized(this){i++;}
2.
AtomicInteger i = new AtomicInteger();i.getAndIncrement();
Update: Thanks for the answers. Is volatile needed when I use AtomicInteger?