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

Synchronized 的实现机制 #89

Open
tbfungeek opened this issue Feb 13, 2020 · 0 comments
Open

Synchronized 的实现机制 #89

tbfungeek opened this issue Feb 13, 2020 · 0 comments

Comments

@tbfungeek
Copy link
Owner

Synchronized 在加锁的时候会使用传入对象的地址作为哈希值,查找到它的SyncData(包含传入对象和一个递归锁的结构体)并加锁,在解锁的时候查找合适的 SyncData 并将其解锁。Synchronized在使用的时候不能将nil对象作为传入对象,但是可以允许在Synchronized范围内传入对象的值变成nil

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

No branches or pull requests

1 participant