image.png\

Future的get方法会阻塞

使用锁来解决

1、对象锁:synchronize(this){}
2、方法同步:synchronize 方法名
3、lock()和unlock()方法

synchronize可以修饰普通方法,也可以修饰静态方法(静态方法不能使用this,因为静态方法不存在this,this是在运行期才可能确定,而静态方法在编译期就确定的了)

image.png