public static void main(String[] args) {
final int[] a = {100};
for (int i = 0; i < 100; i++) {
new Thread(new Runnable() {
@Override
public void run() {
a[0]++;
System.out.println(a[0]);
}
}).start();
}
}
运行结果
101
105
104
103
102
106
107
108
110
109