java - spring boot 事务管理问题求解答
PHP中文网
PHP中文网 2017-04-18 10:23:19
0
1
825

@Transactional(isolation=Isolation.SERIALIZABLE)
public String modifyStock(){
查询库存
thread.sleep(10*1000);

修改库存
}多线程访问这个方法的时候,线程1查询完库存后进入休眠,线程2查询完库存后进入休眠,线程1休眠结束执行修改库存,线程2休眠结束执行修改库存,线程2报获取锁失败。为什么线程2在查询库存的时候没有报获取锁失败,不是加了SERIALIZABLE锁吗?

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
小葫芦

I feel that there should be no lock when querying, but the logic of queuing and submitting transactions is reflected when the transaction is submitted

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!