package GoIntoConcurrency;

/**
 *
 * 一.原子性：
 *
 * Created by chenyang on 2017/2/19.
 */
public class MultiThreadLong {
    public static long t=0;
    public static class ChangeT implements Runnable{
        private long to;

        public ChangeT(long to) {
            this.to = to;
        }

        public void run() {
            while (true){
                MultiThreadLong.t=to;
                Thread.yield();
            }
        }
    }

    public static class ReadT implements Runnable{
        public void run() {
            while (true){
                long tmp=MultiThreadLong.t;
                if(tmp!=111L&&tmp!=-999L&&tmp!=333L&&tmp!=-444L){
                    System.out.println(tmp);
                }
            }
        }
    }

    public static void main(String[] args) {
        new Thread(new ChangeT(111L)).start();
        new Thread(new ChangeT(-999L)).start();
        new Thread(new ChangeT(333L)).start();
        new Thread(new ChangeT(-444)).start();
        new Thread(new ReadT()).start();
    }
}

@@ -37,16 +37,135 @@
 * %E4%B8%80.%E5%8E%9F%E5%AD%90%E6%80%A7%EF%BC%9A
+%E6%8C%87%E4%B8%80%E4%B8%AA%E6%93%8D%E4%BD%9C%E6%98%AF%E4%B8%8D%E5%8F%AF%E4%B8%AD%E6%96%AD%E7%9A%84%E3%80%82%E5%8D%B3%E4%BD%BF%E5%9C%A8%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%80%E8%B5%B7%E6%89%A7%E8%A1%8C%E7%9A%84%E6%97%B6%E5%80%99%EF%BC%8C%E4%B8%80%E4%B8%AA%E6%93%8D%E4%BD%9C%E4%B8%80%E6%97%A6%E5%BC%80%E5%A7%8B%E5%B0%B1%E4%B8%8D%E4%BC%9A%E8%A2%AB%E5%B9%B2%E6%89%B0%E3%80%82%0A * int%E5%9E%8B%E6%98%AF%E5%8E%9F%E5%AD%90%E6%93%8D%E4%BD%9C%E7%B1%BB%E5%9E%8B%E3%80%82%E4%BD%86%E5%9C%A832%E4%BD%8D%E7%B3%BB%E7%BB%9F%E6%9D%A5%E8%AF%B4%EF%BC%8Clong%E5%9E%8B%E6%95%B0%E6%8D%AE%E7%9A%84%E8%AF%BB%E5%86%99%E4%B8%8D%E6%98%AF%E5%8E%9F%E5%AD%90%E7%B1%BB%E5%9E%8B%E7%9A%84%E3%80%82%E5%9B%A0%E4%B8%BAlong%E5%9E%8B%E9%95%BF%E5%BA%A6%E6%98%AF64%E4%BD%8D%E3%80%82%0A * 64%E4%BD%8D%E5%92%8C32%E4%BD%8D%E6%98%AF%E7%B3%BB%E7%BB%9F%E7%9A%84%E5%AF%BB%E5%9D%80%E9%95%BF%E5%BA%A6%E3%80%82
 %0A *%0A * C

update code