Atomic variables in the java.util.concurrent.atomic package support lock-free, thread-safe programming on single variables.
Source Code
AtomicLong atomicLong = new AtomicLong(0);
atomicLong.incrementAndGet(); // Safely increments by one in a multithreaded environment
System.out.println("Atomic value: " + atomicLong.get());