package com.zwy.thread;
public class AtomicDemo {
private static int count=0;
public static void incr() {
synchronized (AtomicDemo.class) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
count++;
}
}
public static void main(String[] args) throws Exception {
for (int i = 0; i < 1000; i++) {
new Thread(()->AtomicDemo.incr()).start();
}
Thread.sleep(5000);
System.out.println(count);
}
}