public class SychronizdDemo {
static Integer count=0;
public static void incr(){
synchronized (count) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
count++;
}
}
public static void main(String[] args) throws IOException, InterruptedException {
for(int i=0;i<1000;i++){
new Thread(()->SychronizdDemo.incr()).start();
}
Thread.sleep(5000);
System.out.println("result:"+count);
}
}
为什么sleep不会释放锁但是输出结果会是小于1000的数??