Atomic Variable

A value supporting thread-safe single operations without an explicit lock.

What is Atomic Variable in Java?

Atomic Variable — A value supporting thread-safe single operations without an explicit lock.

import java.util.concurrent.atomic.AtomicInteger;

class Counter {
    AtomicInteger value = new AtomicInteger();

    void increment() {
        value.incrementAndGet();
    }
}

Level: Master · More Java terms at this level

Updated