这个帖子里提到的概念,也常听别人提到这种说法,其实oracle的doc里几乎没看到这样的叫法...记录一下
http://www.itpub.net/thread-341385-1-1.html
看了下面doc,感觉toms_zhang的解释还是非常到位的:
乐观锁:完全依靠数据库来管理锁的工作。
悲观锁:应用程序自己管理数据或对象上的锁处理
[@more@]Oracle Internals page 57
Consider an airline seat reservation application. Two different customers may
simultaneously ask two different operators whether a seat is available on a
particular flight. What should the application do?
The application can use SELECT FOR UPDATE NOWAIT to retrieve the
information. This guarantees that if a seat appears to be available, then it has
already been locked, and a booking for that seat will be able to be successfully
taken. This is called early locking, or pessimistic locking.
The alternative is to defer the taking of a lock until the customer resolves to make
a booking. This is called late locking, or optimistic locking.
The choice of either pessimistic or optimistic locking affects the design of both
business and application processes. So careful thought is needed. Pessimistic
locking should be avoided where possible, despite being slightly easier to
implement, because it increases the risk of blocking locks.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/19602/viewspace-1056739/
,如需转载,请注明出处,否则将追究法律责任。