Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java多线程之悲观锁与乐观锁 | Cyenq`blog #3

Open
mroccyen opened this issue Aug 12, 2019 · 0 comments
Open

Java多线程之悲观锁与乐观锁 | Cyenq`blog #3

mroccyen opened this issue Aug 12, 2019 · 0 comments

Comments

@mroccyen
Copy link
Owner

https://blog.cyenq.xyz/2017/09/12/20170912-Java%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B9%8B%E6%82%B2%E8%A7%82%E9%94%81%E4%B8%8E%E4%B9%90%E8%A7%82%E9%94%81/

前言乐观锁与悲观锁是一种广义上的概念,体现了看待线程同步的不同角度。在Java和数据库中都有此概念对应的实际应用。可以从以下概念来进行区分: 线程要不要锁住同步资源? 锁住:悲观锁 不锁住:乐观锁 悲观锁概念对于同一数据的并发操作,悲观锁认为自己在使用数据的时候一定有别的线程来修改数据,因此在获取数据的时候会先加锁,确保数据不会被别的线程修改。Java中,synchronized关键字和Loc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant