package com.thinker.common.thread;


public class Volatile{

    public static volatile int count = 0;

    public void increase(){
        count ++;
    }

    public static void main(String[] args) {
        final Volatile test = new Volatile();
        for (int i = 0;i < 10;i++){
            new Thread(() -> {
                for (int j = 0;j < 1000;j++){
                    test.increase();
                }
            }).start();
        }
        while (Thread.activeCount() > 1){
            Thread.yield();
        }
        System.out.println(count);
    }
}
