两个线程分别对int i=0进行i++一百次
测试代码
public class Test {
private static int i = 0;
public static void main(String[] args) {
Runnable runnable = () -> {
for (int j = 0; j < 100; j++) {
i++;
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.p
共有 0 条评论