package interview.baturu;

/**
 * 成员变量非静态变量的多线程问题 类似于 SimpleDateFormat
 * Created by Linuxea on 10/14/17.
 * never forget a shame like this
 */
public class ClassLocalTest {

    private String string = "local";

    public static void main(String[] args) {

        ClassLocalTest classLocalTest = new ClassLocalTest();

        for (int i = 0; i < 100; i++) {
            int temp = i;
            new Thread(() -> {
                classLocalTest.change(temp);
                classLocalTest.print();
            }).start();

        }
    }

    public void change(int i) {
        string = "me" + i;
    }

    public void print() {
        System.out.println(string);
    }

}

@@ -20,16 +20,55 @@
 aturu;%0A%0A
+import java.util.concurrent.TimeUnit;%0A%0A
 /**%0A * %E6%88%90
@@ -496,16 +496,200 @@
 (temp);%0A
+                try %7B%0A                    TimeUnit.MILLISECONDS.sleep(1);%0A                %7D catch (InterruptedException e) %7B%0A                    e.printStackTrace();%0A                %7D%0A
         

添加睡眠时间，放大多线程问题