package com.tazine.thread.concurrent.atomic;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * AtomicInteger
 *
 * @author frank
 * @since 1.0.0
 */
public class AtomicIntegerFeature implements Runnable{

    private AtomicInteger i = new AtomicInteger(0);

    private AtomicInteger getVal(){
        return i;
    }

    private void increment(){
        i.addAndGet(2);
    }

    @Override
    public void run() {
        while (true){
            increment();
        }
    }

    public static void main(String[] args) {

        AtomicIntegerFeature runnable = new AtomicIntegerFeature();

        new Thread(runnable).start();

        while (true){
            int val = runnable.i.get();
            if (val % 2 != 0){
                System.out.println(val + " is not enen");
                System.exit(0);
            }
        }
    }
}

@@ -30,22 +30,19 @@
 current.
-atomic
+cas
 ;%0A%0Aimpor
@@ -204,16 +204,53 @@
 nable%7B%0A%0A
+    /**%0A     * %E4%BD%BF%E7%94%A8 CAS %E5%8F%AF%E4%BB%A5%E9%81%BF%E5%85%8D%E5%8A%A0%E9%94%81%0A     */%0A
     priv

fix (codeplay-thread) : submit the test thread.