import lombok.*;
/*
o.wait();释放锁
...
Thread.sleep(6000);
6004
...
* */
public class T {
@SneakyThrows
public static void main(String[] args) {
Object o = new Object();
new Thread(() -> {
synchronized (o) {
try {
long begin = System.currentTimeMillis();
Thread.sleep(6000);
// o.wait();
System.out.println(System.currentTimeMillis() - begin);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
new Thread(() -> {
synchronized (o) {
System.out.println("...");
}
}).start();
}
}
标签:...,Thread,区别,System,sleep,new,wait
From: https://www.cnblogs.com/goodluckxiaotuanzi/p/18364419