import java.util.concurrent.atomic.AtomicInteger;

public class AtomicVariables {
    public static int normalInt = 0;
    public static AtomicInteger atomicInt = new AtomicInteger(0);
    public static void main(String[] args) throws InterruptedException {
        Thread[] threads = new Thread[10];

        // Create and start 10 threads
        for (int i = 0; i < 10; i++) {
            threads[i] = new Thread(() -> {
                for (int j = 0; j < 10000; j++) {
                    normalInt++;
                    atomicInt.incrementAndGet();
                }
            });
            threads[i].start();
        }

        // Wait for all threads to complete
        for (Thread t : threads) {
            t.join();
        }

        System.out.println("Expected value: 100000");
        System.out.println("Normal integer: " + normalInt);
        System.out.println("Atomic integer: " + atomicInt.get());
    }
}

